Return to bug21957.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / serialize |
1.1 misho 1: --TEST-- 2: Bug #21957 (serialize() mangles objects with __sleep) 3: --FILE-- 4: <?php 5: class test 6: { 7: public $a, $b; 8: 9: function test() 10: { 11: $this->a = 7; 12: $this->b = 2; 13: } 14: 15: function __sleep() 16: { 17: $this->b = 0; 18: } 19: } 20: 21: $t['one'] = 'ABC'; 22: $t['two'] = new test(); 23: 24: var_dump($t); 25: 26: $s = @serialize($t); 27: echo $s . "\n"; 28: 29: var_dump(unserialize($s)); 30: ?> 31: --EXPECT-- 32: array(2) { 33: ["one"]=> 34: string(3) "ABC" 35: ["two"]=> 36: object(test)#1 (2) { 37: ["a"]=> 38: int(7) 39: ["b"]=> 40: int(2) 41: } 42: } 43: a:2:{s:3:"one";s:3:"ABC";s:3:"two";N;} 44: array(2) { 45: ["one"]=> 46: string(3) "ABC" 47: ["two"]=> 48: NULL 49: }