3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php const FRUIT = ['apple','pear','peach']; define('ANIMALS', [ 'dog', 'cat', 'bird' ]); echo ANIMALS[1]; // outputs "cat" echo FRUIT[1]; // outputs "pear" ?>
based on LLLK8
Output for 7.0.0 - 7.2.0
catpear
Output for 5.6.8 - 5.6.28
Warning: Constants may only evaluate to scalar values in /in/sD6DL on line 9 Notice: Use of undefined constant ANIMALS - assumed 'ANIMALS' in /in/sD6DL on line 11 Npear
Output for 5.4.2 - 5.5.35
Fatal error: Arrays are not allowed as constants in /in/sD6DL on line 3
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/sD6DL on line 3
Process exited with code 255.