PHP Tutorial - PHP serialize() function






We can use serialize() to save objects into a string, then use urlencode() to get a format suitable for the web.

Syntax

PHP serialize() has the following syntax.

serialize($aVariable);

Example

Serialize a class


<?PHP
class ComputerBook{ }
$aBook = new ComputerBook;
$safepoppy = urlencode(serialize($aBook));
?>