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)[0]; var_dump($b);
based on sks4C
Output for 7.2.0
array(3) { ["class@anonymous/in/ov2YC0x7febe147004ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7febe147004ba"
Output for 7.1.10
array(3) { ["class@anonymous/in/ov2YC0x7f5a6718f04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f5a6718f04ba"
Output for 7.1.7
array(3) { ["class@anonymous/in/ov2YC0x7f664235904ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f664235904ba"
Output for 7.1.6
array(3) { ["class@anonymous/in/ov2YC0x7f024986004ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f024986004ba"
Output for 7.1.5
array(3) { ["class@anonymous/in/ov2YC0x7f3b3c42504ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f3b3c42504ba"
Output for 7.1.0
array(3) { ["class@anonymous/in/ov2YC0x7f485540d04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f485540d04ba"
Output for 7.0.20
array(3) { ["class@anonymous/in/ov2YC0x7f142407804ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f142407804ba"
Output for 7.0.6
array(3) { ["class@anonymous/in/ov2YC0x7f9da8f8604ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f9da8f8604ba"
Output for 7.0.5
array(3) { ["class@anonymous/in/ov2YC0x7fdec870104ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7fdec870104ba"
Output for 7.0.4
array(3) { ["class@anonymous/in/ov2YC0x7f35db32504ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f35db32504ba"
Output for 7.0.3
array(3) { ["class@anonymous/in/ov2YC0x7fb6c62d404ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7fb6c62d404ba"
Output for 7.0.2
array(3) { ["class@anonymous/in/ov2YC0x7f6ae105404ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f6ae105404ba"
Output for 7.0.1
array(3) { ["class@anonymous/in/ov2YC0x7f5fb4a5a04ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f5fb4a5a04ba"
Output for 7.0.0
array(3) { ["class@anonymous/in/ov2YC0x7f129e0e004ba"]=> int(3) ["*b"]=> int(2) ["c"]=> int(1) } string(1) "" string(42) "class@anonymous/in/ov2YC0x7f129e0e004ba"
Output for 5.4.11 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/ov2YC 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/ov2YC on line 3
Process exited with code 255.