PHP is still more commonly used, so I studied the PHP variable serialization, here to take out and share with you, I hope it is useful to everyone. Serialization is probably the form of converting some variables into a byte stream of strings, which is easier to transmit and store. Of course, off is the transfer of storage nothing, the key is to become a string of the form can be converted back, but also to maintain the structure of the original data.
Serialization is probably the form of converting some variables into a byte stream of strings, which is easier to transmit and store. Of course, off is the transfer of storage nothing, the key is to become a string of the form can be converted back, but also to maintain the structure of the original data. A function that has multiple serialization in PHP: Serialize (), which converts any variable value (except a resource variable) into a string, can save the string to a file, or register as a session, or use curl to simulate get/post to transfer variables, Achieve the effect of RPC. If you want to convert the serialized variable to PHP's original variable value, you can use the Unserialize () function.
Serialization of PHP variables
Let's take a simple example to illustrate the serialization of PHP variables and its storage format.
Integral type :
- $ var ;
Output: i:23;
floating point type :
- $ var 1.;
Output: d:1.229999999999999982236431605997495353221893310546875;
string :
- $ var "This is a string";
- Echo Serialize ($var);
- $ var "I am a variable";
Output: s:16: "This is a string"; S:8: "I am a variable";
Boolean type :
- $ var true;
- Echo Serialize ($var);
- $ var false;
Output: b:1;b:0;
After serialization of these basic types, it is clear that the storage format after serialization is: variable type: [variable length:] variable value; that is, the first character represents the variable type, the second: the partition, the variable length is optional, is in the string type, the other type is not, the last one is the variable value, Each serialized value is ";" As the end.
http://www.bkjia.com/PHPjc/446492.html www.bkjia.com true http://www.bkjia.com/PHPjc/446492.html techarticle PHP is still more commonly used, so I studied the PHP variable serialization, here to take out and share with you, I hope it is useful to everyone. Serialization is probably the conversion of some variables into ...