Back to vBulletin 3 Articles

The joys of serializing data
by filburt1 18 Jun 2003

To serialize a variable or object in PHP means to take the variable or object and convert it to a string that can be stored anywhere, including, relevant to vB, a MySQL database. Later, it can be unserialized, at which point it'll be (nearly) exactly the same as when it was serialized.

An example:
PHP Code:
$serialized serialize($myobject);
.
.
.
$myobjectagain unserialize($serialized);
$myobjectagain->method(); 
Remember to addslashes $serialized when making a query because it could contain quotes. Also note that some tiny things can be lost when serializing; namely, internal array pointers, among others.

Reference:
http://www.php.net/serialize
http://www.php.net/unserialize (way faster than serializing)

vblts.ru supports vBulletin®, 2022-2024