3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { function test($p) { $p[] = 'test'; } } $tp = ['asd','sad']; $tc = new test(); $tc->test($tp); var_dump($tp); die; abstract class T { static public $instanses; final private function __construct(){ } public static function getInstance() { if (!(static::$instanses instanceof static)) { static::$instanses = new static; } return static::$instanses; } } class A extends T { static public $instanses; } class B extends A { static public $instanses; } $t = A::getInstance(); var_dump($t); $t1 = B::getInstance(); var_dump($t1); new B(); ?>
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
array(2) { [0]=> string(3) "asd" [1]=> string(3) "sad" }
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/NvBaP on line 2 Fatal error: Uncaught ArgumentCountError: Too few arguments to function test::test(), 0 passed in /in/NvBaP on line 8 and exactly 1 expected in /in/NvBaP:3 Stack trace: #0 /in/NvBaP(8): test->test() #1 {main} thrown in /in/NvBaP on line 3
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught ArgumentCountError: Too few arguments to function test::test(), 0 passed in /in/NvBaP on line 8 and exactly 1 expected in /in/NvBaP:3 Stack trace: #0 /in/NvBaP(8): test->test() #1 {main} thrown in /in/NvBaP on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; test has a deprecated constructor in /in/NvBaP on line 2 Warning: Missing argument 1 for test::test(), called in /in/NvBaP on line 8 and defined in /in/NvBaP on line 3 array(2) { [0]=> string(3) "asd" [1]=> string(3) "sad" }
Output for 5.4.9 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Warning: Missing argument 1 for test::test(), called in /in/NvBaP on line 8 and defined in /in/NvBaP on line 3 array(2) { [0]=> string(3) "asd" [1]=> string(3) "sad" }

preferences:
179.99 ms | 402 KiB | 219 Q