3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_prime($n) { if ($n <= 1) { return false; } elseif ($n <= 3) { return true; } elseif (($n % 2 == 0) || ($n % 3 == 0)) { return false; } $i = 5; while ($i * $i <= $n) { if (($n % $i == 0) || ($n % ($i + 2) == 0)) { return false; $i = $i + 6; } } return true; } function prime_gen() { for($x=0; $x< PHP_INT_MAX; $x++) { if(is_prime($x)){ yield $x; } } } function nth_prime($n) { $nth = 0; foreach (prime_gen() as $prime) { if (++$nth >= $n) { break; } } return $prime; } echo nth_prime(9);
Output for git.master, git.master_jit, rfc.property-hooks
23

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:
61.88 ms | 401 KiB | 8 Q