📑 Table of Contents

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

edit

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

edit
  1. ^ "Serialization". PHP Internals Book. Retrieved 2020-07-05.
  2. ^ "PHP: serialize - Manual". PHP: Hypertext Preprocessor. Retrieved 2020-07-05.
  3. ^ "Response Writers | Apache Solr Reference Guide 8.5". lucene.apache.org. Retrieved 2020-07-05.
edit

📚 Artikel Terkait di Wikipedia

Comparison of data-serialization formats

This is a comparison of data serialization formats, various ways to convert complex objects to sequences of bits. It does not include markup languages

Serialization

serialization (or serialisation, also referred to as pickling in Python) is the process of translating a data structure or object state into a format

INI file

recently, data serialization formats, such as JSON, TOML, and YAML, can serve as configuration formats. These three alternative formats can nest arbitrarily

FlatBuffers

FlatBuffers is a free software library implementing a serialization format similar to Protocol Buffers, Thrift, Apache Avro, SBE, and Cap'n Proto, primarily

Protocol Buffers

Nim, Perl, PHP, Prolog, R, Rust, Scala, and Swift. Free and open-source software portal gRPC Comparison of binary data serialization formats FlatBuffers

PHP

2019-04-05. "PHP: rfc:deprecate-and-remove-ext-wddx". wiki.php.net. Retrieved 2019-04-05. "PHP: rfc:custom_object_serialization". wiki.php.net. Retrieved

YAML

YAML. Comparison of data-serialization formats provides a more comprehensive comparison of YAML with other serialization formats. For fixed data structures

MessagePack

Perl, PHP, Python, Ruby, Rust, Scala, Smalltalk, and Swift. Data structures processed by MessagePack loosely correspond to those used in JSON format. They