PHP serialize() function

In this chapter you will learn:

  1. Why do we need PHP serialize()
  2. Syntax for PHP serialize()
  3. Example - serialize a class

Description

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//from   j a  va 2 s.c o m
class ComputerBook{ }
$aBook = new ComputerBook;
$safepoppy = urlencode(serialize($aBook));
?>

Next chapter...

What you will learn in the next chapter:

  1. Description for PHP boolval function
  2. Syntax for PHP boolval function
  3. Parameter for PHP boolval function
  4. Return value for PHP boolval function
  5. Example - What is the boolean value for converted from real value
Home » PHP Tutorial » PHP Class Functions
PHP class_exists() function
PHP get_class() function
PHP get_declared_classes() function
PHP get_declared_interfaces() function
PHP get_defined_functions() function
PHP instanceof
PHP serialize() function