In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shares a sample analysis of PHP variable serialization storage formats. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
PHP is still more commonly used, so I studied PHP variable serialization, here to share with you, I hope useful to you. Serialization is roughly converting some variables into a byte stream of strings, which is easier to transmit and store. Of course, there is nothing to do with transmission and storage. The key is that it can be converted back into a string form and can maintain the original data structure.
Serialization is roughly converting some variables into a byte stream of strings, which is easier to transmit and store. Of course, there is nothing to do with transmission and storage. The key is that it can be converted back into a string form and can maintain the original data structure. In PHP there is a multi-serialization function: serialize(), which converts any variable value (except resource variables) into string form, saves the string to a file, registers it as a Session, or even uses curl to simulate GET/POST to transfer variables to achieve RPC effect. If you want to convert serialized variables to PHP raw variable values, you can use the unserialize() function.
PHP variable serialization
Let's take a simple example of PHP variable serialization and its storage format.
Integer:
$var = 23; echo serialize($var);
Output: i:23;
Floating point type:
$var = 1.23; echo serialize($var);
Output: d: 1.22999999999999998223643160599749535321893310546875;
String:
$var = "This is a string"; echo serialize($var); $var = "I am a variable"; echo serialize($var);
Output: s:16:"This is a string";s:8:"I am a variable";
Boolean:
$var = true; echo serialize($var); $var = false; echo serialize($var);
Output: b:1;b:0;
The above basic types after serialization is very clear, the storage format after serialization is: variable type:[variable length:] variable value; that is, the *** bit character represents the variable type, the second: represents the partition, the variable length is optional, that is, in the string type, other types do not, *** one is the variable value, each serialized value ends with ";".
Thank you for reading! About "PHP variable serialization storage format example analysis" This article is shared here, I hope the above content can be of some help to everyone, so that we can learn more knowledge, if you think the article is good, you can share it to let more people see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.