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