PHP unserialize() Function

❮ PHP Variable Handling Reference

Example

Convert serialized data back into actual data:

<?php
$data = serialize(array("Red", "Green", "Blue"));
echo $data . "<br>";

$test = unserialize($data);
var_dump($test);
?>
Try it Yourself »

Definition and Usage

The unserialize() function converts serialized data back into actual data.


Syntax

unserialize(string, options);

Parameter Values

Parameter Description
string Required. Specifies the serialized string
options Optional. Specifies options to be provided to the function, as an associative array. Can be either an array of class names which should be accepted, false to accept no classes, or true to accept all classes. True is default.

Technical Details

Return Value: The converted value. Can be a boolean, integer, float, string, array or object. FALSE, and an E_NOTICE on failure
Return Type: Boolean, integer, float, string, array or object
PHP Version: 4.0+
PHP Changelog: PHP 7.0: Added the options parameter

❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.