Very useful two PHP functions: serialize () and unserialize ()

Source: Internet
Author: User

Today, I am doing something about the PING service, because I don't want to put the ping service address into the database, that's not good. The ping service is not an inefficient task, and then put it into the database, this not only reduces the program efficiency, but also brings unnecessary losses to the server. Therefore, we try to put the ping service address in an array. in the conf file, the initial design idea is to put the generated php code. PHP file, and then put. the PHP file was loaded in. Later, it was found that the operation was not very convenient. Therefore, I decided to use the serialize () function and the unserialize () function. The usage of these two functions is really out of the box. One is to store serialized functions, the other is serialization and recovery, which is very convenient. The code for function usage is shared: Copy codeThe Code is as follows: <? Php
$ Array = array ();
$ Array ['key'] = 'website ';
$ Array ['value'] = 'www ';
$ A = serialize ($ array );
Echo $;
Unset ($ array );
$ A = unserialize ($ );
Print_r ($ );

If you do not write a specific usage, you can think for yourself, and then try again. Here, I am talking about only one way of thinking and method. The specific usage should be studied by myself.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.