3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function __wakeup() { echo 'In foo', PHP_EOL, PHP_EOL; throw new \Exception('Foo'); } public function __destruct() { echo 'Destruct foo', PHP_EOL, PHP_EOL; throw new \Exception('Foo destruct'); } } class Bar { public function __wakeup() { echo 'In bar', PHP_EOL, PHP_EOL; throw new \Exception('Bar'); } public function __destruct() { echo 'Destruct bar', PHP_EOL, PHP_EOL; throw new \Exception('Bar destruct'); } } try { unserialize(serialize([$f = new Foo, $b = new Bar])); } catch (\Throwable $e) { echo $e, PHP_EOL, PHP_EOL; } echo "==========", PHP_EOL, PHP_EOL; try { unserialize(serialize([$b, $f])); } catch (\Throwable $e) { echo $e, PHP_EOL, PHP_EOL; }
Output for 7.0.10 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
In foo Exception: Foo in /in/82UJj:6 Stack trace: #0 [internal function]: Foo->__wakeup() #1 /in/82UJj(28): unserialize('a:2:{i:0;O:3:"F...') #2 {main} ========== In bar Exception: Bar in /in/82UJj:18 Stack trace: #0 [internal function]: Bar->__wakeup() #1 /in/82UJj(36): unserialize('a:2:{i:0;O:3:"B...') #2 {main} Destruct bar Fatal error: Uncaught Exception: Bar destruct in /in/82UJj:23 Stack trace: #0 [internal function]: Bar->__destruct() #1 {main} thrown in /in/82UJj on line 23
Process exited with code 255.
Output for 7.0.0 - 7.0.9
In foo Destruct foo Exception: Foo in /in/82UJj:6 Stack trace: #0 [internal function]: Foo->__wakeup() #1 /in/82UJj(28): unserialize('a:2:{i:0;O:3:"F...') #2 {main} Next Exception: Foo destruct in /in/82UJj:11 Stack trace: #0 [internal function]: Foo->__destruct() #1 /in/82UJj(28): unserialize('a:2:{i:0;O:3:"F...') #2 {main} ========== In bar Destruct bar Exception: Bar in /in/82UJj:18 Stack trace: #0 [internal function]: Bar->__wakeup() #1 /in/82UJj(36): unserialize('a:2:{i:0;O:3:"B...') #2 {main} Next Exception: Bar destruct in /in/82UJj:23 Stack trace: #0 [internal function]: Bar->__destruct() #1 /in/82UJj(36): unserialize('a:2:{i:0;O:3:"B...') #2 {main} Destruct bar Fatal error: Uncaught Exception: Bar destruct in /in/82UJj:23 Stack trace: #0 [internal function]: Bar->__destruct() #1 {main} thrown in /in/82UJj on line 23
Process exited with code 255.
Output for 5.6.30 - 5.6.40
In foo Fatal error: Uncaught exception 'Exception' with message 'Foo' in /in/82UJj:6 Stack trace: #0 [internal function]: Foo->__wakeup() #1 /in/82UJj(28): unserialize('a:2:{i:0;O:3:"F...') #2 {main} thrown in /in/82UJj on line 6
Process exited with code 255.
Output for 5.4.14 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.29
In foo Destruct foo Fatal error: Uncaught exception 'Exception' with message 'Foo' in /in/82UJj:6 Stack trace: #0 [internal function]: Foo->__wakeup() #1 /in/82UJj(28): unserialize('a:2:{i:0;O:3:"F...') #2 {main} Next exception 'Exception' with message 'Foo destruct' in /in/82UJj:11 Stack trace: #0 /in/82UJj(0): Foo->__destruct() #1 {main} thrown in /in/82UJj on line 11
Process exited with code 255.
Output for 5.4.0 - 5.4.13
In foo Destruct foo Destruct bar Fatal error: Uncaught exception 'Exception' with message 'Foo' in /in/82UJj:6 Stack trace: #0 [internal function]: Foo->__wakeup() #1 /in/82UJj(28): unserialize('a:2:{i:0;O:3:"F...') #2 {main} Next exception 'Exception' with message 'Foo destruct' in /in/82UJj:11 Stack trace: #0 /in/82UJj(0): Foo->__destruct() #1 {main} Next exception 'Exception' with message 'Bar destruct' in /in/82UJj:23 Stack trace: #0 /in/82UJj(0): Bar->__destruct() #1 {main} thrown in /in/82UJj on line 23
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/82UJj on line 28
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 23 Parse error: syntax error, unexpected '[', expecting ')' in /in/82UJj on line 28
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 6 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 18 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/82UJj on line 23 Parse error: parse error, unexpected '[', expecting ')' in /in/82UJj on line 28
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/82UJj on line 4
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/82UJj 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/82UJj on line 4
Process exited with code 255.

preferences:
304.46 ms | 401 KiB | 468 Q