3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function perfect($n) { if ($n < 1) { echo "Number has to be Positive."; return false; } for($i = 1; $i <= $n; $i++) { if ($n % $i == 0) { $factors[] = $i; } else { echo "$factors[1] $factors[2] $factors[3]"; } } return ($n == array_sum($factors) / 2) ? true : false; } perfect(42); ?>
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined offset: 3 in /in/LanSr on line 12 2 3 Notice: Undefined offset: 3 in /in/LanSr on line 12 2 3 2 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 6
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 3 in /in/LanSr on line 12 2 3 Notice: Undefined index: 3 in /in/LanSr on line 12 2 3 2 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 6
Output for 5.2.3 - 5.2.17
Notice: Undefined offset: 3 in /in/LanSr on line 12 2 3 Notice: Undefined offset: 3 in /in/LanSr on line 12 2 3 2 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 6
Output for 4.3.0 - 5.2.2
Notice: Undefined index: 3 in /in/LanSr on line 12 2 3 Notice: Undefined index: 3 in /in/LanSr on line 12 2 3 2 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 62 3 6