3v4l.org

run code in 300+ PHP versions simultaneously
<?php function x($n) { for($i = 1; $i <= $n; $i++) { if ($n % $i == 0 && $i != $n) { $factors[] = $i; echo "$i is a factor of $n." . PHP_EOL; } elseif ($i == $n) { echo "Removing $n from array.." . PHP_EOL; } } if ($n == array_sum($a) / 2) { echo "It's perfect!" . PHP_EOL; } else { echo "It's not perfect!" . PHP_EOL; } } x(42); ?>
Output for git.master_jit, git.master, rfc.property-hooks
1 is a factor of 42. 2 is a factor of 42. 3 is a factor of 42. 6 is a factor of 42. 7 is a factor of 42. 14 is a factor of 42. 21 is a factor of 42. Removing 42 from array.. Warning: Undefined variable $a in /in/CFWhN on line 12 Fatal error: Uncaught TypeError: array_sum(): Argument #1 ($array) must be of type array, null given in /in/CFWhN:12 Stack trace: #0 /in/CFWhN(12): array_sum(NULL) #1 /in/CFWhN(20): x(42) #2 {main} thrown in /in/CFWhN on line 12
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.93 ms | 401 KiB | 8 Q