3v4l.org

run code in 300+ PHP versions simultaneously
<?php $p = 1; for ($i = 1; $i <= 3; $i++) { echo '$p before calculation: ' . $p . PHP_EOL; for ($k = 1; $k <= $i; $k++) { $p = $p * 3; } echo '$p after calculation: ' . $p . PHP_EOL; } echo '$p at end of script: ' . $p . PHP_EOL; echo '=====' . PHP_EOL; unset($p); // just for having both examples at once for ($i = 1; $i <= 3; $i++) { $p = 1; echo '$p before calculation: ' . $p . PHP_EOL; for ($k = 1; $k <= $i; $k++) { $p = $p * 3; } echo '$p after calculation: ' . $p . PHP_EOL; } echo '$p at end of script: ' . $p . PHP_EOL;
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
$p before calculation: 1 $p after calculation: 3 $p before calculation: 3 $p after calculation: 27 $p before calculation: 27 $p after calculation: 729 $p at end of script: 729 ===== $p before calculation: 1 $p after calculation: 3 $p before calculation: 1 $p after calculation: 9 $p before calculation: 1 $p after calculation: 27 $p at end of script: 27
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
81.37 ms | 407 KiB | 5 Q