3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param int $num1 * @param ?int $num2 If null or omitted, it will get the value 1 * * @return int */ function add($num1, $num2 = null) { // If the default value is null, set it to the default $num2 = $num2 ?? 1; print_r($num1, $num2); return $num1 + $num2; } $bool = true; echo add(5, $bool ? 5 : null) . PHP_EOL; $bool = false; echo add(5, $bool ? 5 : null) . PHP_EOL;
Output for git.master_jit, git.master, rfc.property-hooks
10 6

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:
26.72 ms | 405 KiB | 5 Q