3v4l.org

run code in 300+ PHP versions simultaneously
<?php function v1($first, $last) { $result = trim($first); $lastName = trim($last); if ($lastName) { if (!empty($result)) { $result .= ' '; } $result .= $lastName; } return $result; } function v2($first, $last) { return implode(" ", [trim($first), trim($last)]); } function v($first, $last) { echo v1($first, $last); echo PHP_EOL; echo v2($first, $last); } v();
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught ArgumentCountError: Too few arguments to function v(), 0 passed in /in/p1RP2 on line 29 and exactly 2 expected in /in/p1RP2:22 Stack trace: #0 /in/p1RP2(29): v() #1 {main} thrown in /in/p1RP2 on line 22
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20
Warning: Missing argument 1 for v(), called in /in/p1RP2 on line 29 and defined in /in/p1RP2 on line 22 Warning: Missing argument 2 for v(), called in /in/p1RP2 on line 29 and defined in /in/p1RP2 on line 22 Notice: Undefined variable: first in /in/p1RP2 on line 24 Notice: Undefined variable: last in /in/p1RP2 on line 24 Notice: Undefined variable: first in /in/p1RP2 on line 26 Notice: Undefined variable: last in /in/p1RP2 on line 26

preferences:
204.44 ms | 403 KiB | 243 Q