Two very useful PHP functions serialize() and unserialize()_PHP Tutorial

WBOY
Release: 2016-07-21 15:21:47
Original
976 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:

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

I haven’t written too specific usage. Children’s shoes can think about it by themselves and then try it. Again, what I’m talking about here is just an idea and method. You still have to study it yourself for specific usage.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324863.htmlTechArticleToday, I am working on something about the PING service, because I don’t want to put the ping service address into the database, which would be inappropriate. Okay, the ping service is not an inefficient thing, and then put it into the database...
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