The idea behind serializing a variable is to create a storable string format of it, such that the same variable can be recreated later when required using the string.
1. serialize and unserialize
These are the traditional functions to serialize and unserialize data in PHP.
CODE:
$a = array('a' => 'Apple' ,'b' => 'banana' , 'c' => 'Coconut');
//serialize the array
$s = serialize($a);
echo $s;
//a:3:{s:1:"a";s:5:"Apple";s:1:"b";s:6:"banana";s:1:"c";s:7:"Coconut";}
echo '
';
//unserialize
$o = unserialize($s);
print_r($o);
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-735652/
,如需转载,请注明出处,否则将追究法律责任。