Home > PHP > Function > Variable handling > serialize()

serialize()

serialize - Generates a storable representation of a value

Syntax

string serialize (mixed $value)

Arguments

  • 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 serializing will also be stored. Any other reference will be lost. When serializing objects, PHP will attempt to call the member function __sleepprior 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 __wakeupmember function is called. Note: Object\'s private members have the class name prepended to the member name; protected members have a \'*\' prepended to the member name. These prepended values have null bytes on either side.

Description

Generates a storable representation of a value

Version

PHP 4, 5

Return value

Returns a string containing a byte-stream representation of value that can be stored anywhere.