3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class ArrayAccessObject implements ArrayAccess { public function offsetSet($offset, $value){} public function offsetUnset($offset){} public function offsetExists($offset){} public function offsetGet($offset){ echo gettype($offset) . "\n"; } } $array = ['a', 'b', 'c']; $object = new ArrayAccessObject(); $string = '1'; $object[1]; // 'integer' $object['1']; // 'integer' <-- should be string $object[1.0]; // 'double' $object['1.0']; // 'double' $object[true]; // 'boolean' $object[$string]; // 'string' $object[$object]; // 'object' $object[$array]; // 'array'
Output for 5.6.30, 7.0.0 - 7.2.9
integer integer double string boolean string object array
Output for hhvm-3.15.4 - 3.22.0
integer string double string boolean string object array