Generates a storable representation of a value
This is useful for storing or passing PHP values around without losing their type and structure.
To make the serialized string into a PHP value again, use unserialize().
value
The value to be serialized. serialize() handles all types, except the resource-type. You can even serialize() arrays that contain references to itself. Circular references inside the array/object you are serialize()ing will also be stored. Any other reference will be lost.
When serializing objects, PHP will attempt to call the member function __sleep() prior to serialization. This is to allow the object to do any last minute clean-up, etc. prior to being serialized. Likewise, when the object is restored using unserialize() the __wakeup() member function is called.
Returns a string containing a byte-stream representation of
value
that can be stored anywhere.
Version | Description |
---|---|
4.0.7 | The object serialization process was fixed. |
4.0.0 | When serializing an object, methods are not lost anymore. Please see the Serializing Objects for more information. |