3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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(); ?>
based on ZICbp
Output for 7.1.0 - 7.2.0
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.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.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" }
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/NvBaP on line 7
Process exited with code 255.