serialize
Function • Params and return types changed in PHP 8.0
Generates a storable representation of a value.
serialize Function synopsis
serialize(mixed $value): string
Parameters
$value
Typemixed
The value to be serialized. serialize
handles all types, except the resource-type and some objects (see note below).
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.
Return value
Typestring
Returns a string containing a byte-stream representation of
$value that can be stored anywhere.
Note that this is a binary string which may include null bytes, and needs
to be stored and handled as such. For example,
serialize output should generally be stored in a BLOB
field in a database, rather than a CHAR or TEXT field.
Changes to the serialize Function
PHP 8.0
- Return type added:
string - Parameter name of parameter #1 changed:
$varto$value - Parameter type added for parameter #1 (
$value):mixed
- serialize($var)
+ serialize(mixed $value): string serialize Function Availability
serialize Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |