3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A implements Serializable { public function unserialize($p) { echo 'uns'; } public function serialize() { return ''; } } class B { public function __wakeup() { echo 'wak';throw Exception; } public function __destruct() { echo 'des'; } } $g[]=new B; $g[]=new A; echo serialize($g); $s='a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}'; var_dump(unserialize($s));
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: A 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/HBf0T on line 2 a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}unswak Fatal error: Uncaught Error: Undefined constant "Exception" in /in/HBf0T:12 Stack trace: #0 [internal function]: B->__wakeup() #1 /in/HBf0T(22): unserialize('a:2:{i:0;O:1:"B...') #2 {main} thrown in /in/HBf0T on line 12 des
Process exited with code 255.
Output for 8.0.0 - 8.0.30
a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}unswak Fatal error: Uncaught Error: Undefined constant "Exception" in /in/HBf0T:12 Stack trace: #0 [internal function]: B->__wakeup() #1 /in/HBf0T(22): unserialize('a:2:{i:0;O:1:"B...') #2 {main} thrown in /in/HBf0T on line 12 des
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}unswak Warning: Use of undefined constant Exception - assumed 'Exception' (this will throw an Error in a future version of PHP) in /in/HBf0T on line 12 Fatal error: Uncaught Error: Can only throw objects in /in/HBf0T:12 Stack trace: #0 [internal function]: B->__wakeup() #1 /in/HBf0T(22): unserialize('a:2:{i:0;O:1:"B...') #2 {main} thrown in /in/HBf0T on line 12
Process exited with code 255.
Output for 7.0.15 - 7.0.20, 7.1.1 - 7.1.33
a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}unswak Notice: Use of undefined constant Exception - assumed 'Exception' in /in/HBf0T on line 12 Fatal error: Uncaught Error: Can only throw objects in /in/HBf0T:12 Stack trace: #0 [internal function]: B->__wakeup() #1 /in/HBf0T(22): unserialize('a:2:{i:0;O:1:"B...') #2 {main} thrown in /in/HBf0T on line 12
Process exited with code 255.
Output for 7.0.10 - 7.0.14, 7.1.0
a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}wak Notice: Use of undefined constant Exception - assumed 'Exception' in /in/HBf0T on line 12 Fatal error: Uncaught Error: Can only throw objects in /in/HBf0T:12 Stack trace: #0 [internal function]: B->__wakeup() #1 /in/HBf0T(22): unserialize('a:2:{i:0;O:1:"B...') #2 {main} thrown in /in/HBf0T on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.9
a:2:{i:0;O:1:"B":0:{}i:1;C:1:"A":0:{}}wak Notice: Use of undefined constant Exception - assumed 'Exception' in /in/HBf0T on line 12 des Fatal error: Uncaught Error: Can only throw objects in /in/HBf0T:12 Stack trace: #0 [internal function]: B->__wakeup() #1 /in/HBf0T(22): unserialize('a:2:{i:0;O:1:"B...') #2 {main} thrown in /in/HBf0T on line 12
Process exited with code 255.

preferences:
171.11 ms | 401 KiB | 193 Q