3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $arr = array("test"); function bar( $str ){ $val = $this->{arr[0]}; var_dump($val); if ( is_callable( self::$val ) ){ self::{$this->arr[0]}( $str ); } } static function test($var) { echo "Testing: $var\n"; } } (new Foo)->bar("bla");
based on fSSU1
Output for 7.2.0
Warning: Use of undefined constant arr - assumed 'arr' (this will throw an Error in a future version of PHP) in /in/1mn3S on line 7 Notice: Undefined property: Foo::$a in /in/1mn3S on line 7 NULL Fatal error: Uncaught Error: Access to undeclared static property: Foo::$val in /in/1mn3S:9 Stack trace: #0 /in/1mn3S(20): Foo->bar('bla') #1 {main} thrown in /in/1mn3S on line 9
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant arr - assumed 'arr' in /in/1mn3S on line 7 Notice: Undefined property: Foo::$a in /in/1mn3S on line 7 NULL Fatal error: Uncaught Error: Access to undeclared static property: Foo::$val in /in/1mn3S:9 Stack trace: #0 /in/1mn3S(20): Foo->bar('bla') #1 {main} thrown in /in/1mn3S on line 9
Process exited with code 255.
Output for 5.6.8 - 5.6.21
Notice: Use of undefined constant arr - assumed 'arr' in /in/1mn3S on line 7 Notice: Undefined property: Foo::$a in /in/1mn3S on line 7 NULL Fatal error: Access to undeclared static property: Foo::$val in /in/1mn3S on line 9
Process exited with code 255.
Output for 5.3.22 - 5.5.35
Parse error: syntax error, unexpected '[' in /in/1mn3S on line 7
Process exited with code 255.