3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $var['foo'] = array('fooooo', 'bar'); $a = reset(array_slice($var['foo'], 0, 1)); var_dump($a); $a['foo'][0] = 'bar'; var_dump($a);
Output for 7.0.0 - 7.1.0
Notice: Only variables should be passed by reference in /in/C9Zsn on line 4 string(6) "fooooo" Warning: Illegal string offset 'foo' in /in/C9Zsn on line 8 Fatal error: Uncaught Error: Cannot use string offset as an array in /in/C9Zsn:8 Stack trace: #0 {main} thrown in /in/C9Zsn on line 8
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Strict Standards: Only variables should be passed by reference in /in/C9Zsn on line 4 string(6) "fooooo" Warning: Illegal string offset 'foo' in /in/C9Zsn on line 8 Fatal error: Cannot use string offset as an array in /in/C9Zsn on line 8
Process exited with code 255.
Output for 5.1.0 - 5.3.29
Strict Standards: Only variables should be passed by reference in /in/C9Zsn on line 4 string(6) "fooooo" Fatal error: Cannot use string offset as an array in /in/C9Zsn on line 8
Process exited with code 255.
Output for 5.0.5
Fatal error: Only variables can be passed by reference in /in/C9Zsn on line 4
Process exited with code 255.
Output for 5.0.0 - 5.0.4
string(6) "fooooo" Fatal error: Cannot use string offset as an array in /in/C9Zsn on line 8
Process exited with code 255.
Output for 4.3.0 - 4.4.9
string(6) "fooooo" string(6) "fooooo"