Annotation of embedaddon/php/ext/standard/tests/serialize/001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: serialize()/unserialize()/var_dump()
! 3: --INI--
! 4: serialize_precision=100
! 5: --FILE--
! 6: <?php
! 7: class t
! 8: {
! 9: function t()
! 10: {
! 11: $this->a = "hallo";
! 12: }
! 13: }
! 14:
! 15: class s
! 16: {
! 17: public $a;
! 18: public $b;
! 19: public $c;
! 20:
! 21: function s()
! 22: {
! 23: $this->a = "hallo";
! 24: $this->b = "php";
! 25: $this->c = "world";
! 26: $this->d = "!";
! 27: }
! 28:
! 29: function __sleep()
! 30: {
! 31: echo "__sleep called\n";
! 32: return array("a","c");
! 33: }
! 34:
! 35: function __wakeup()
! 36: {
! 37: echo "__wakeup called\n";
! 38: }
! 39: }
! 40:
! 41:
! 42: echo serialize(NULL)."\n";
! 43: echo serialize((bool) true)."\n";
! 44: echo serialize((bool) false)."\n";
! 45: echo serialize(1)."\n";
! 46: echo serialize(0)."\n";
! 47: echo serialize(-1)."\n";
! 48: echo serialize(2147483647)."\n";
! 49: echo serialize(-2147483647)."\n";
! 50: echo serialize(1.123456789)."\n";
! 51: echo serialize(1.0)."\n";
! 52: echo serialize(0.0)."\n";
! 53: echo serialize(-1.0)."\n";
! 54: echo serialize(-1.123456789)."\n";
! 55: echo serialize("hallo")."\n";
! 56: echo serialize(array(1,1.1,"hallo",NULL,true,array()))."\n";
! 57:
! 58: $t = new t();
! 59: $data = serialize($t);
! 60: echo "$data\n";
! 61: $t = unserialize($data);
! 62: var_dump($t);
! 63:
! 64: $t = new s();
! 65: $data = serialize($t);
! 66: echo "$data\n";
! 67: $t = unserialize($data);
! 68: var_dump($t);
! 69:
! 70: $a = array("a" => "test");
! 71: $a[ "b" ] = &$a[ "a" ];
! 72: var_dump($a);
! 73: $data = serialize($a);
! 74: echo "$data\n";
! 75: $a = unserialize($data);
! 76: var_dump($a);
! 77: ?>
! 78: --EXPECTF--
! 79: N;
! 80: b:1;
! 81: b:0;
! 82: i:1;
! 83: i:0;
! 84: i:-1;
! 85: i:2147483647;
! 86: i:-2147483647;
! 87: d:1.123456789000000011213842299184761941432952880859375;
! 88: d:1;
! 89: d:0;
! 90: d:-1;
! 91: d:-1.123456789000000011213842299184761941432952880859375;
! 92: s:5:"hallo";
! 93: a:6:{i:0;i:1;i:1;d:1.100000000000000088817841970012523233890533447265625;i:2;s:5:"hallo";i:3;N;i:4;b:1;i:5;a:0:{}}
! 94: O:1:"t":1:{s:1:"a";s:5:"hallo";}
! 95: object(t)#%d (1) {
! 96: ["a"]=>
! 97: string(5) "hallo"
! 98: }
! 99: __sleep called
! 100: O:1:"s":2:{s:1:"a";s:5:"hallo";s:1:"c";s:5:"world";}
! 101: __wakeup called
! 102: object(s)#%d (3) {
! 103: ["a"]=>
! 104: string(5) "hallo"
! 105: ["b"]=>
! 106: NULL
! 107: ["c"]=>
! 108: string(5) "world"
! 109: }
! 110: array(2) {
! 111: ["a"]=>
! 112: &string(4) "test"
! 113: ["b"]=>
! 114: &string(4) "test"
! 115: }
! 116: a:2:{s:1:"a";s:4:"test";s:1:"b";R:2;}
! 117: array(2) {
! 118: ["a"]=>
! 119: &string(4) "test"
! 120: ["b"]=>
! 121: &string(4) "test"
! 122: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>