3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { var $my_public = array(); //forward php4 to constructor function foo() { $this->my_public[] = 'php4 constructor'; return $this->__construct(); } //constructor php5 function __construct() { $this->my_public[] = 'php4 constructor'; register_shutdown_function(array(&$this, "__destruct")); } function dump() { print_r($this->my_public); } } $test = new foo();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: register_shutdown_function(): Argument #1 ($callback) must be a valid callback, class foo does not have a method "__destruct" in /in/XOEOu:19 Stack trace: #0 /in/XOEOu(19): register_shutdown_function(Array) #1 /in/XOEOu(29): foo->__construct() #2 {main} thrown in /in/XOEOu on line 19
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: register_shutdown_function(): Invalid shutdown callback 'foo::__destruct' passed in /in/XOEOu on line 19
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Redefining already defined constructor for class foo in /in/XOEOu on line 15 Warning: register_shutdown_function(): Invalid shutdown callback 'foo::__destruct' passed in /in/XOEOu on line 19
Output for 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/XOEOu on line 4 Strict Standards: Redefining already defined constructor for class foo in /in/XOEOu on line 15 Warning: register_shutdown_function(): Invalid shutdown callback 'foo::__destruct' passed in /in/XOEOu on line 19
Output for 5.0.5, 5.1.0 - 5.1.1
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/XOEOu on line 4 Strict Standards: Redefining already defined constructor for class foo in /in/XOEOu on line 15 Warning: (Registered shutdown functions) Unable to call foo::__destruct() - function does not exist in Unknown on line 0
Output for 5.0.0 - 5.0.4
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/XOEOu on line 4 Strict Standards: Redefining already defined constructor for class foo in /in/XOEOu on line 15 Warning: Unknown: Unable to call () - function does not exist in Unknown on line 0
Output for 4.4.0 - 4.4.9
Warning: (Registered shutdown functions) Unable to call foo::__destruct() - function does not exist in Unknown on line 0
Output for 4.3.0 - 4.3.11
Warning: Unknown(): Unable to call () - function does not exist in Unknown on line 0

preferences:
231.97 ms | 401 KiB | 329 Q