3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class B { function va2() { return 22; } public $v3=19; function __construct() { $this->va = function() { return []; }; } } $o=new B; var_dump(($o->va)()); var_dump(($o['va'])()); var_dump($o['va']());
based on 56lZb
Output for 7.0.0 - 7.2.0
array(0) { } Fatal error: Uncaught Error: Cannot use object of type B as array in /in/gGbPe:19 Stack trace: #0 {main} thrown in /in/gGbPe on line 19
Process exited with code 255.
Output for 5.4.11 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/gGbPe on line 18
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/gGbPe on line 12
Process exited with code 255.