<?php
class Foo {
public function __sleep() {
return "Baz";
}
}
class Bar implements Serializable{
public function serialize() {
return "Baz";
}
public function unserialize($data) {
}
}
$foo = new Foo;
$bar = new Bar;
var_dump(serialize($foo));
var_dump(serialize($bar));
Deprecated: Bar implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /in/HSVMS on line 9
Warning: serialize(): Foo::__sleep() should return an array only containing the names of instance-variables to serialize in /in/HSVMS on line 21
string(2) "N;"
string(17) "C:3:"Bar":3:{Baz}"
Output for 8.0.0 - 8.0.30
Warning: serialize(): Foo::__sleep() should return an array only containing the names of instance-variables to serialize in /in/HSVMS on line 21
string(2) "N;"
string(17) "C:3:"Bar":3:{Baz}"
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize in /in/HSVMS on line 21
string(2) "N;"
string(17) "C:3:"Bar":3:{Baz}"
Output for 7.3.32 - 7.3.33
string(2) "N;"
string(17) "C:3:"Bar":3:{Baz}"
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.4
Notice: serialize(): __sleep should return an array only containing the names of instance-variables to serialize. in /in/HSVMS on line 21
string(2) "N;"
string(17) "C:3:"Bar":3:{Baz}"
Output for 5.0.5
Fatal error: Interface 'Serializable' not found in /in/HSVMS on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.4
Fatal error: Class 'Serializable' not found in /in/HSVMS on line 9
Process exited with code 255.
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/HSVMS 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/HSVMS 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/HSVMS on line 4
Process exited with code 255.