3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * @author: hakre <http://hakre.wordpress.com> * @link http://stackoverflow.com/a/17628617/367456 */ /** * dereference a value and optionally setting its type * * @param mixed $mixed * @param null $type (optional) * * @return mixed $mixed set as $type */ function rettype($mixed, $type = NULL) { $type === NULL || settype($mixed, $type); return $mixed; } $array = Array('status' => ['Figure A. ...' => ['regions' => [1,2,34]]]); echo rettype($array, 'object')->status; // prints "Figure A. ..."
Output for 5.4.0 - 7.1.0
Notice: Array to string conversion in /in/l08eR on line 22 Array
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/l08eR on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/l08eR on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/l08eR on line 20
Process exited with code 255.