3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $number = 100; $primes = [1,2,3,5,7,11,13,17]; foreach ($primes as $prime) { if ($number % prime == 0) { echo "$number is divisible by $prime\n"; } else { echo "$number is NOT divisible by $prime\n"; } }
based on Hn5lq
Output for 7.2.0
Warning: Use of undefined constant prime - assumed 'prime' (this will throw an Error in a future version of PHP) in /in/g3LUj on line 7 Warning: A non-numeric value encountered in /in/g3LUj on line 7 Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /in/g3LUj:7 Stack trace: #0 {main} thrown in /in/g3LUj on line 7
Process exited with code 255.
Output for 7.1.0 - 7.1.10
Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: A non-numeric value encountered in /in/g3LUj on line 7 Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /in/g3LUj:7 Stack trace: #0 {main} thrown in /in/g3LUj on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /in/g3LUj:7 Stack trace: #0 {main} thrown in /in/g3LUj on line 7
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 1 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 2 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 3 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 5 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 7 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 11 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 13 Notice: Use of undefined constant prime - assumed 'prime' in /in/g3LUj on line 7 Warning: Division by zero in /in/g3LUj on line 7 100 is divisible by 17
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/g3LUj on line 4
Process exited with code 255.