Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP compatible serialization from C/C++

Tags:

php

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?

like image 438
psychotik Avatar asked Jul 28 '09 23:07

psychotik


People also ask

How can I serialize data in PHP?

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.

How does PHP serialization work?

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.

What is serialization in PHP give example?

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.

Which two functions are used for Serialisation in PHP?

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.


2 Answers

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.

like image 140
Frank Farmer Avatar answered Oct 22 '22 22:10

Frank Farmer


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)

like image 3
Brenton Alker Avatar answered Oct 22 '22 22:10

Brenton Alker