serialized are two very useful PHP functions serialize and unserialize

WBOY
Release: 2016-07-29 08:47:55
Original
970 people have browsed it

Today, I am working on something about the PING service. I don’t want to put the ping service address into the database. That is not good. The ping service is not an inefficient thing. Putting it into the database will not only reduce the efficiency of the program even more. , and also brought unnecessary losses to the server, so I tried to find a way to put the ping service address into the .conf file in the form of an array. The initial design idea was to put the generated php code into the .php file, and then Then load the .php file. Later, I found that it was inconvenient to operate, so I decided to use the serialize() function and unserialize() function. The usage of these two functions is really a perfect match. One is for serialization and storage, and the other is for serialization and storage. One is to perform serialization recovery, which is extremely convenient. Function usage code sharing:

Copy code The code is as follows:


$array = array();
$array['key' ] = 'website';
$array['value']='www.chhua.com';
$a = serialize($array);
echo $a;
unset($array);
$a = unserialize ($a);
print_r($a);
?>


didn’t write too specific usage, children’s shoes can think for themselves and then try, again, what I’m talking about here is just an idea and method, You still have to study the specific usage yourself.

The above has introduced two very useful PHP functions serialize and unserialize, including serialized content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template