Two very useful PHP functions serialize of and unserialize of

  • 2020-05-12 02:22:22
  • OfStack

Today, doing a about PING service, because don't want to put ping service address in the database, it is not good, ping service was not a efficiency is not high, and then into the database, more not only decrease the efficiency of the program, back to the server to bring unnecessary loss, so the ping service address is to find a way to use in the array. conf file, began to design train of thought is by generating php code in. php file, and then put the. php file loaded in, later, found that is not very convenient to operate, So, I decided to use the serialize() and unserialize() functions. The two functions are a perfect match. One is for serialization storage, and the other is for serialization recovery.
 
<?php 
$array = array(); 
$array['key'] = 'website'; 
$array['value']='www.chhua.com'; 
$a = serialize($array); 
echo $a; 
unset($array); 
$a = unserialize($a); 
print_r($a); 
?> 

Did not write too specific use, children can think, and then try, or the sentence, I said here is only one way of thinking and method, specific use, or to study.

Related articles: