Anyone know of a library that allows data to be serialized in C++ such that it can be deserialized using the default PHP 'unserialize' function?
To get the POST values from serializeArray in PHP, use the serializeArray() method. The serializeArray( ) method serializes all forms and form elements like the . serialize() method but returns a JSON data structure for you to work with.
Definition and Usage. The serialize() function converts a storable representation of a value. To serialize data means to convert a value to a sequence of bits, so that it can be stored in a file, a memory buffer, or transmitted across a network.
Serializing an object means converting it to a bytestream representation that can be stored in a file. This is useful for persistent data; for example, PHP sessions automatically save and restore objects.
Serializing objects - objects in sessions ¶ serialize() returns a string containing a byte-stream representation of any value that can be stored in PHP. unserialize() can use this string to recreate the original variable values. Using serialize to save an object will save all variables in an object.
There are several implementations for other languages here
http://objectmix.com/php/362009-specification-serialize.html#post1335166
The C implementation used by PHP itself is also here:
http://svn.php.net/repository/php/php-src/branches/PHP_5_2/ext/standard/var.c
http://svn.php.net/repository/php/php-src/branches/PHP_5_2/ext/standard/var_unserializer.c
However, unless you're absolutely certain that your choice serialization format is going to be a major bottleneck, consider using a more readily available serialization format, like JSON, XML, Protocol Buffers, or WDDX.
Since you're probably only serializing data, and not PHP objects, you may find a standardized "common ground" serialization more effective. (JSON is likely the simplest)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With