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;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
150.72 ms | 1725 KiB | 13 Q