3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $x = get_object_vars(json_decode('{"2":1}')); $y = (object)$x; $exprs = ['isset($x[2])', 'isset($x["2"])', 'isset($y->{2})', 'isset($y->{"2"})', '$x', '$y']; var_dump(array_map(function ($expr) use ($x, $y) { return eval("return $expr;"); }, array_combine($exprs, $exprs)));
based on ijU2D
Output for 7.2.0 - 7.3.0alpha1
array(6) { ["isset($x[2])"]=> bool(true) ["isset($x["2"])"]=> bool(true) ["isset($y->{2})"]=> bool(true) ["isset($y->{"2"})"]=> bool(true) ["$x"]=> array(1) { [2]=> int(1) } ["$y"]=> object(stdClass)#1 (1) { ["2"]=> int(1) } }
Output for 5.6.0 - 5.6.30, 7.0.17 - 7.0.20, 7.1.3 - 7.1.7
array(6) { ["isset($x[2])"]=> bool(true) ["isset($x["2"])"]=> bool(true) ["isset($y->{2})"]=> bool(false) ["isset($y->{"2"})"]=> bool(false) ["$x"]=> array(1) { [2]=> int(1) } ["$y"]=> object(stdClass)#1 (1) { [2]=> int(1) } }
Output for hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.0.16, 7.1.0 - 7.1.2
array(6) { ["isset($x[2])"]=> bool(false) ["isset($x["2"])"]=> bool(false) ["isset($y->{2})"]=> bool(true) ["isset($y->{"2"})"]=> bool(true) ["$x"]=> array(1) { ["2"]=> int(1) } ["$y"]=> object(stdClass)#1 (1) { ["2"]=> int(1) } }