3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = array(1,2,3,4,5); $l = count($a); for ($i=0; $i < $l-2; $i++) { echo $a[$i]; } echo $a[l-2]; echo $a[l-1];
based on pBrru
Output for 7.1.0
123 Notice: Use of undefined constant l - assumed 'l' in /in/NMm0S on line 7 Warning: A non-numeric value encountered in /in/NMm0S on line 7 Notice: Undefined offset: -2 in /in/NMm0S on line 7 Notice: Use of undefined constant l - assumed 'l' in /in/NMm0S on line 8 Warning: A non-numeric value encountered in /in/NMm0S on line 8 Notice: Undefined offset: -1 in /in/NMm0S on line 8
Output for 5.3.0 - 7.0.14
123 Notice: Use of undefined constant l - assumed 'l' in /in/NMm0S on line 7 Notice: Undefined offset: -2 in /in/NMm0S on line 7 Notice: Use of undefined constant l - assumed 'l' in /in/NMm0S on line 8 Notice: Undefined offset: -1 in /in/NMm0S on line 8
Output for 4.3.0 - 5.2.17
123 Notice: Use of undefined constant l - assumed 'l' in /in/NMm0S on line 7 Notice: Undefined offset: -2 in /in/NMm0S on line 7 Notice: Use of undefined constant l - assumed 'l' in /in/NMm0S on line 8 Notice: Undefined offset: -1 in /in/NMm0S on line 8