3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($var) { echo "Test $var"; } class foo { var $arr = array("test"); /*function test($var) { echo "Test $var"; }*/ } class moo { static public $arr = array("test"); /*function test($var) { echo "Test $var"; }*/ } $a = new foo(); var_dump($a);; $a->arr[0]("testvalue"); moo::$arr[0]("another one"); ?>
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, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
object(foo)#1 (1) { ["arr"]=> array(1) { [0]=> string(4) "test" } } Test testvalueTest another one
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
object(foo)#1 (1) { ["arr"]=> array(1) { [0]=> string(4) "test" } } Test testvalue Notice: Undefined variable: arr in /in/9kvM5 on line 36 Fatal error: Function name must be a string in /in/9kvM5 on line 36
Process exited with code 255.

preferences:
186.55 ms | 402 KiB | 236 Q