3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* * call property by deferencing array * */ class myStr { public $s = "yet another string"; function getStr(){ return $this->s; } } class Nothing {} $arr = array(); $obj1 = new myStr; $obj2 = new Nothing; echo [$obj1,$obj2][0]->s;
based on eJCW3
Output for 7.0.0 - 7.2.0
yet another string
Output for 5.5.24 - 5.6.28
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ';' in /in/l6KH5 on line 18
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '[', expecting ',' or ';' in /in/l6KH5 on line 18
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/l6KH5 on line 18
Process exited with code 255.