Home > Backend Development > PHP Tutorial > Serialization of objects into strings and deserialization into objects in php

Serialization of objects into strings and deserialization into objects in php

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:32:56
Original
1337 people have browsed it

class Car {
Public $name = 'car';

Public function __clone() {
         $obj = new Car();
$obj->name = $this->name;
}
}
$a = new Car();
$a->name = 'new car';
$b = clone $a;
if ($a == $b) echo '=='; //true
if ($a === $b) echo '==='; //false Quote

$str = serialize($a); //Object serialized into string
echo $str.'
';
$c = unserialize($str); //Deserialize to object

var_dump($c);




The above introduces the serialization of objects into strings and deserialization into objects in PHP, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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