Usage of PHP unserialize and serialize

Source: Internet
Author: User

Introduction: This is a detailed page for PHP unserialize and serialize usage. It introduces the knowledge, skills, and experience related to the usage of PHP, PHP, serialize, unserialize, and unserialize, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 351504 'rolling = 'no'>

PHP provides two functions: serialize serialization and unserialize deserialization. What is the use of these two functions? Serialization can serialize any data type in PHP into a string except resource. Here, we take an object as an example to define a class Vb {private $ A; private $ B; function _ construct ($ A = 'peng', $ B = 'luo') {$ this-> A = $ A; $ this-> B = $ B ;} public Function speak () {return $ this->. $ this-> B ;}}$ OBJ = new VB (); We serialize $ OBJ $ c = serialize ($ OBJ); after printing $ C, we get o: 2: "VB": 2 {s: 5: "VBA"; s: 4: "peng"; s: 5: "vBB"; s: 3: "Luo";} We Will deserialize this string, $ c = unserialize ($ C); print print_r ($ C); Vb object ([: private] => Peng [B: Private] => LUO) Now we get an object. We can call the attributes and methods of the object echo $ C-> speak (); in fact, these two functions are not difficult, but many people do not know when to use them. What is the use of these functions, when you want to save a complex data type to a file or database, you can see its role.

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/351504.html pageno: 3

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: info-contact@alibabacloud.com 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.