Change language

PHP SplObjectStorage serialize () function

Syntax:
string SplObjectStorage::serialize()
Parameters:this the function does not take any parameters.Return value:this function returns a string that is a storage representation.The following programs illustrate the SplObjectStorage function::serialize()in PHP:Program 1:  
// Create a new storage class $str = new SplObjectStorage; $obj = new StdClass; $str -> attach ( $obj , " GeeksforGeeks " );  
// Print serialization result echo $str -> serialize(); ?>
Exit:
x: i : 1; O: 8: "stdClass": 0: {}, s: 13: "GeeksforGeeks" ;; m: a: ​​0: {}
Program 2: $obj1 = new StdClass; $obj2 = new StdClass;  
// Create a new storage class $gfg1 = new SplObjectStorage(); $gfg1 [ $obj1 ] = "Geeks" ;  
// Create a new storage class $gfg2 = new SplObjectStorage(); $gfg2 [ $obj1 ] = "GFG" ; $gfg2 [ $obj2 ] = "GeeksClasses" ; print_r ( $gfg1 -> serialize(). " " ); echo ( $gfg2 -> serialize(). "" );  
?>
Exit:
x: i : 1; O: 8: "stdClass": 0: {}, s: 5: "Geeks" ;; m: a: ​​0: {} x: i: 2; O: 8: "stdClass": 0: { }, s: 3: "GFG" ;; O: 8: "stdClass": 0: {}, s: 12: "GeeksClasses" ;; m: a: ​​0: {}
Link: https://www.php.net/manual/en/splobjectstorage.serialize.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method