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 v3($str1, $str2) { return (strlen($str1) > 0 && strlen($str2) > 0) ? ($str1 + " " + $str2) : (strlen($str1) > 0) ? $str1 : $str2 ; } function v($first, $last) { echo v1($first, $last); echo PHP_EOL; echo v2($first, $last); echo PHP_EOL; echo v3($first, $last); } v('first', 'second');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Unparenthesized `a ? b : c ? d : e` is not supported. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/6nJem on line 24
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)` in /in/6nJem on line 24 first second first second Warning: A non-numeric value encountered in /in/6nJem on line 24 Warning: A non-numeric value encountered in /in/6nJem on line 24 Warning: A non-numeric value encountered in /in/6nJem on line 24 second
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
first second first second Warning: A non-numeric value encountered in /in/6nJem on line 24 Warning: A non-numeric value encountered in /in/6nJem on line 24 Warning: A non-numeric value encountered in /in/6nJem on line 24 second
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
first second first second second

preferences:
226.73 ms | 402 KiB | 269 Q