PHP serialization format

The PHP serialization format is the serialization format used by the PHP programming language. The format can serialize PHP's primitive and compound types, and also properly serializes references.[1] The format was first introduced in PHP 4.[2]

In addition to PHP, the format is also used by some third-party applications that are often integrated with PHP applications, for example by Lucene/Solr.[3]

## Syntax

The syntax generally follows the pattern of one-letter code of the variable type, followed by a colon and the length of the data, followed by the variable value, and ending with a semicolon. For the associative array, the format is `<serialised key> ; <serialised value>`, repeated for each association/pair in the array.

Type  | Serialization examples

|

Null  | `N;`
Boolean  | `b:1;`
`b:0;`
Integer  | `i:685230;`
`i:-685230;`
Floating point  | `d:685230.15;`
`d:INF;`
`d:-INF;`
`d:NAN;`
String  | `s:5:"apple";`
`s:6:"A to Z";`
Associative array  | `a:4:{i:0;b:1;i:1;N;i:2;d:-421000000;i:3;s:6:"A to Z";}`
`a:2:{i:42;b:1;s:6:"A to Z";a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}}`
Object  | `O:8:"stdClass":2:{s:4:"John";d:3.14;s:4:"Jane";d:2.718;}`
Reference  | `a:2:{i:0;s:3:"foo";i:1;R:2;}`

## References

1. ↑ "Serialization". http://www.phpinternalsbook.com/php5/classes_objects/serialization.html.
2. ↑ "PHP: serialize - Manual". https://www.php.net/manual/en/function.serialize.php.
3. ↑ "Response Writers | Apache Solr Reference Guide 8.5". https://lucene.apache.org/solr/guide/8_5/response-writers.html#php-writer.

## External links

* PHP Scripts
* PHP: Serialize

* v
* t
* e

PHP

People|

* Andi Gutmans
* Rasmus Lerdorf
* Zeev Suraski

Resources|

* Accelerator (List)
* Composer
* Editors
* Libraries
* PEAR

Implementations|

* HHVM
* HPHPc
* Parrot
* PeachPie
* Phalanger
* Quercus
* Zend Engine

Web frameworks|

* CakePHP
* CodeIgniter
* Drupal
* eZ Publish
* Fat-Free
* FuelPHP
* Horde
* Joomla!
* Laravel
* Li3 (formerly Lithium)
* Midgard
* MODx
* Nette Framework
* Phalcon
* Pop PHP
* PHP-Fusion
* PRADO
* Qcodo
* Silex
* SilverStripe
* Symfony
* TYPO3
* WordPress
* XOOPS
* Yii
* Zend Framework
* Zeta Components

Testing|

* Behat
* PHPUnit
* Lime (Symfony)

ORMs|

* Doctrine
* Propel

IDEs|

* Aptana
* Codelobster
* Eclipse PDT
* NetBeans
* PHPEdit
* PhpStorm
* RadPHP
* Zend Studio

Widget toolkit|

* PHP-GTK
* wxPHP

* Category
* Commons

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/PHP serialization format. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=PHP_serialization_format&oldid=3980598"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template