2 ion\serialize/serializable
8 class test implements Serializable {
10 function serialize() : string {
13 function unserialize(string $data) : void {
18 class recursive implements Serializable {
24 function serialize() : string {
26 return "node:" . ion\serialize($this->r);
31 function unserialize(string $data) : void {
32 if ($data === "leaf") {
35 $this->id = substr($data, 0, 4);
36 $this->r = ion\unserialize(substr($data, 5));
44 $s = ion\serialize([$t, $t]);
46 $c = ion\unserialize($s);
48 $tree = new recursive(new recursive(null));
50 $s = ion\serialize($tree);
52 debug_zval_dump(ion\unserialize($s));
58 Deprecated: test implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %sserialize/serializable.php on line %d
60 Deprecated: recursive implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in %sserialize/serializable.php on line %d
62 [S::test::{{"foobar"}},r::1]
65 object(test)#%d (1) refcount(2){
67 string(6) "foobar" refcount(1)
70 object(test)#%d (1) refcount(2){
72 string(6) "foobar" refcount(1)
75 object(recursive)#%d (2) {
76 ["id":"recursive":private]=>
79 object(recursive)#%d (2) {
80 ["id":"recursive":private]=>
86 S::recursive::{{"node:S::recursive::{{\"leaf\"}}"}}
87 object(recursive)#%d (2) refcount(1){
88 ["id":"recursive":private]=>
89 string(4) "node" refcount(1)
91 object(recursive)#%d (2) refcount(1){
92 ["id":"recursive":private]=>
93 string(4) "leaf" refcount(1)