AJSHP Project :: CONTRIBUTE
bugs reports
To send me a report of a bug, use this email address with subject
[AJSHP] and here your real subject
andreaIHATESPAM3siteIHATESPAMit
I need your help
I need your help to create other server-side implementations of serialize / unserialize PHP functions to
use this project in other languages too (C#, Python, Java or others).
PHP as you know, is not fast ( in standard clear and not byteencoded or compiled mode ) as other compiled or byte-encoded program / script languages,
then the best solution for a server-side execution is to use internal PHP core functions,
such serialize and unserialize, created and compiled with C program language.
That's why this server-side interaction mode is faster and requires less resources than
JSON PHP implementation (I mean the class, maybe faster than compiled JSON for PHP version too).
So, the function, class or object that I need should be able to convert variables, nested too, in this way:
-
boolean
b:value;
true <=> b:1;
false <=> b:0; -
number
i:value; or d:value;
integer <=> i:N; (i.e. 1234 <=> i:1234; or -1234 <=> i:-1234;)
float or double <=> d:R; (i.e. 1.2 <=> d:1.2; or -1.2 <=> d:-1.2;) -
string
s:length:"value";
test <=> s:4:"test";
if there are single or double quotes don't add slash (i.e. a"b <=> s:3:"a"b";)
note that utf8 encoded strings are stranges in php serializzation, it counts length in bytes and not in chars, however an utf8 uncompatible version should be a great start point too because client serializer object should works without problems ( problems exists only with php but this class interaction is for js, that works fine, and not for php ;-) ) -
array
a:length:{i:index;[serialized value];s:length:"key_name";[serialized value]}
Array() <=> a:0:{}
Array('test1', 'test2') <=> a:2:{i:0;s:5:"test1";i:1;s:5:"test2";}
Array(k1:'test1', k2:'test2') <=> a:2:{s:2:"k1";s:5:"test1";s:2:"k2";s:5:"test2";}
Array('test1', k1:'test2') <=> a:2:{i:0;s:5:"test1";s:2:"k1";s:5:"test2";} -
Object
O:Name_length:"Name":N_vars:{s:v_name_length:"v_name";[serialized value]}
In PHP you need an instance of the serialized Object if you want to use them.
This means that static variables and all methods are not necessary, just public, private and protected vars are serialized or unserialized (names and values are important, everything else is inside class instance).
In javascript these kind of vars will require an instance too, that if is not present will be created automatically as generic function (i.e. returned_var = new Name()) with internal variables (privates and protected are preserved).
NOTE: this symbol ¤ is the \000 char
class TestPub { public $public_var = 0; }O:7:"TestPub":1:{s:10:"public_var";i:0;}
class TestPri { private $private_var = 1; }O:7:"TestPri":1:{s:20:"¤TestPri¤private_var";i:1;}
class TestPro { protected $protected_var = 1; }O:7:"TestPro":1:{s:16:"¤*¤protected_var";i:2;}
-
undefined or null
null <=> N;
P.S. I know Java, Python and C# but I don't know thoose languages as good as I know PHP or ECMA script, then I'll try by mysef to create them but I think that an optimized version should be the real solution for each language.
If you want to know more about PHP compatible serializzation / unserializzation please look at my PHP_Serializer javascript Object or inside PHP serialize and unserialize source code functions.