<?php
class C {
public $a = true;
public function __sleep() {
return array('a', 1);
}
}
$a = new C;
$s = serialize($a);
var_dump($s);
var_dump(unserialize($s));
Warning: serialize(): C::__sleep() should return an array only containing the names of instance-variables to serialize in /in/81nem on line 13
Warning: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/81nem on line 13
string(24) "O:1:"C":1:{s:1:"a";b:1;}"
object(C)#2 (1) {
["a"]=>
bool(true)
}
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/81nem on line 13
Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in /in/81nem on line 13
string(34) "O:1:"C":2:{s:1:"a";b:1;s:1:"1";N;}"
object(C)#2 (2) {
["a"]=>
bool(true)
["1"]=>
NULL
}
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/81nem on line 13
string(26) "O:1:"C":2:{s:1:"a";b:1;N;}"
Notice: unserialize(): Error at offset 25 of 26 bytes in /in/81nem on line 15
bool(false)
Output for 5.2.5 - 5.2.17
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize in /in/81nem on line 13
string(26) "O:1:"C":2:{s:1:"a";b:1;N;}"
Notice: unserialize(): Error at offset 25 of 26 bytes in /in/81nem on line 15
bool(false)
Output for 5.0.5
Process exited with code 139.
Output for 5.0.0 - 5.0.2
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/81nem on line 13
string(26) "O:1:"C":2:{s:1:"a";b:1;N;}"
Notice: unserialize(): Unexpected end of serialized data in /in/81nem on line 15
Notice: unserialize(): Error at offset 25 of 26 bytes in /in/81nem on line 15
bool(false)
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/81nem on line 4
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/81nem on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/81nem on line 4
Process exited with code 255.