3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RefMef { private $_; public function __construct($ref) { $this->_ = $ref; } } class RoleStorage extends SPLObjectStorage { public function serialize() { return parent::serialize(); } public function unserialize($serialized) { var_dump($serialized); parent::unserialize($serialized); } } $obj1 = new RefMef(1); $obj2 = new RefMef($obj1); $test = new RoleStorage; $test->attach($obj2); $test->attach($obj1); echo $ser = serialize($test), "\n"; $try = unserialize($ser);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Return type of RoleStorage::unserialize($serialized) should either be compatible with SplObjectStorage::unserialize(string $data): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/etitf on line 16 Deprecated: Return type of RoleStorage::serialize() should either be compatible with SplObjectStorage::serialize(): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/etitf on line 13 O:11:"RoleStorage":2:{i:0;a:4:{i:0;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}}i:1;N;i:2;r:4;i:3;N;}i:1;a:0:{}}
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
O:11:"RoleStorage":2:{i:0;a:4:{i:0;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}}i:1;N;i:2;r:4;i:3;N;}i:1;a:0:{}}
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33
C:11:"RoleStorage":96:{x:i:2;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}},N;;r:4;,N;;m:a:0:{}} string(96) "x:i:2;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}},N;;r:4;,N;;m:a:0:{}"
Output for 5.3.0 - 5.3.29
C:11:"RoleStorage":96:{x:i:2;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}},N;;r:2;,N;;m:a:0:{}} string(96) "x:i:2;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}},N;;r:2;,N;;m:a:0:{}"
Output for 5.2.2 - 5.2.17
C:11:"RoleStorage":90:{x:i:2;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}};r:2;;m:a:0:{}} string(90) "x:i:2;O:6:"RefMef":1:{s:9:"RefMef_";O:6:"RefMef":1:{s:9:"RefMef_";i:1;}};r:2;;m:a:0:{}"
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.1
O:11:"RoleStorage":0:{}
Output for 5.0.0 - 5.0.5
Fatal error: Class 'SPLObjectStorage' not found in /in/etitf on line 11
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/etitf on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/etitf on line 5
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/etitf on line 5
Process exited with code 255.

preferences:
246.39 ms | 401 KiB | 344 Q