3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $arr = array("test"); function bar( $str ){ var_dump($this->arr[0]); var_dump(is_callable(self."::".$this->arr[0])); self::{$this->arr[0]}( $str ); } static function test($var) { echo "Testing: $var\n"; } } (new Foo)->bar("bla");
based on UWnTA
Output for 7.2.0
string(4) "test" Warning: Use of undefined constant self - assumed 'self' (this will throw an Error in a future version of PHP) in /in/bORlN on line 8 bool(true) Testing: bla
Output for 5.4.12 - 7.1.10
string(4) "test" Notice: Use of undefined constant self - assumed 'self' in /in/bORlN on line 8 bool(true) Testing: bla
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '{', expecting T_STRING or T_VARIABLE or '$' in /in/bORlN on line 9
Process exited with code 255.