PHP » PYTHON |
login |
register |
about
|
PYTHON unserialize
is this article helpful?
|
Python replacement for PHP's unserialize
[
edit
| history
]
pip install phpserialize
from phpserialize import serialize, unserialize str = serialize({'loginip': '127.0.0.1', 'uid': 96, 'loginfrom': 4, 'logintime': 1317200595}) print str print unserialize(str) or import pickle target = file("objects.dat") # open file myObj = pickle.load(target) unserialize(PHP 4, PHP 5) unserialize — Creates a PHP value from a stored representation Descriptionunserialize() takes a single serialized variable and converts it back into a PHP value. Parameters
Return ValuesThe converted value is returned, and can be a boolean, integer, float, string, array or object. In case the passed string is not unserializeable, FALSE is returned and E_NOTICE is issued. Changelog
Examples
Example #1 unserialize() example
<?php
Example #2 unserialize_callback_func example
<?php
NotesWarning
FALSE is returned both in the case of an error and if unserializing the serialized FALSE value. It is possible to catch this special case by comparing str with serialize(false) or by catching the issued E_NOTICE. |
more
Recently updated
more
Most requested
more
Last requests
|