3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $foo = new class { private $a = 3; protected $b = 2; public $c = 1; }; $arr = (array)$foo; var_dump($arr); var_dump(array_keys($arr)[0][0]); $b = array_keys($arr)[2]; var_dump($b);
based on MDB5J
Output for 7.2.0
array(3) { ["class@anonymous/in/1BakW0x7f7d7ebec04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.1.10
array(3) { ["class@anonymous/in/1BakW0x7fb1aebb204ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.1.7
array(3) { ["class@anonymous/in/1BakW0x7f621d4a404ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.1.6
array(3) { ["class@anonymous/in/1BakW0x7f983357204ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.1.5
array(3) { ["class@anonymous/in/1BakW0x7fa04bcc904ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.1.0
array(3) { ["class@anonymous/in/1BakW0x7f53e83e404ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.20
array(3) { ["class@anonymous/in/1BakW0x7f14dfdd504ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.6
array(3) { ["class@anonymous/in/1BakW0x7f356c02d04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.5
array(3) { ["class@anonymous/in/1BakW0x7fea930d704ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.4
array(3) { ["class@anonymous/in/1BakW0x7fc31f99004ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.3
array(3) { ["class@anonymous/in/1BakW0x7f165b13e04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.2
array(3) { ["class@anonymous/in/1BakW0x7f2b5121b04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.1
array(3) { ["class@anonymous/in/1BakW0x7f3635aa504ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 7.0.0
array(3) { ["class@anonymous/in/1BakW0x7fe25e09d04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(1) "c"
Output for 5.4.11 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/1BakW on line 3
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/1BakW on line 3
Process exited with code 255.