001.phpt 2.1 KB

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