How to unserialize a stored representation of PHP value (objects, arrays, etc.)?
To unserialize and obtain a representation of this data:
- Fill in the editor, copy-paste, or browse a file.
- Choose the data display format: JSON or PHP.
- Then click the "Unserialize" button.
The result will be displayed in the second editor. You can retrieve the representation using the "Copy to Clipboard" or "Download" buttons.
How does this PHP unserializer work?
This tool uses the JavaScript library js-php-unserialize. It allows for unserializing and converting the serialized PHP data into JSON.
Note that array()
will be converted to {}
and not []
. A less obvious conversion is array('a', 'b')
which will be converted to {"0": "a", "1": "b"}
.
Depending on the settings, the JSON is either stringified or converted back into PHP.
Why unserialize stored representation of PHP value?
Serialization allows you to convert a PHP value (object, array, etc.) into a string that can be easily stored or transmitted. This is useful in situations where data needs to be persistently saved and later retrieved in its original form.
Deserialization, on the other hand, allows you to reconstruct this data back to its original form for use.
For example, when a user logs out of a session, their data can be serialized for temporary storage. When they log back in, this data is deserialized to restore the state of their session.
The stored representation of a PHP value is not very readable. Obtaining a JSON or PHP representation makes it much more understandable, allowing for a clearer interpretation of the value!