/ /, , : - .
, PHP; , sur .
, JSON PHP, , - Javascript PHP.
, :
class A {
public $a;
public function __construct($a) {
$this->a = $a;
}
}
$test = new A(10);
Now let's serialize and unserialize $ test:
var_dump(unserialize(serialize($test)));
We get:
object(A)[2]
public 'a' => int 10
those. object, an instance of class A.
Now do the same with JSON:
var_dump(json_decode(json_encode($test)));
Now we only have an instance of stdClass:
object(stdClass)[2]
public 'a' => int 10
JSON is nice to share data (information about "class A" is important for PHP, but probably does not make much sense for another application); but also has its limitations.
source
share