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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
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/GVNsR on line 24
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 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/GVNsR 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/GVNsR on line 24 first second first second Warning: A non-numeric value encountered in /in/GVNsR on line 24 Warning: A non-numeric value encountered in /in/GVNsR on line 24 Warning: A non-numeric value encountered in /in/GVNsR on line 24 second
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33
first second first second Warning: A non-numeric value encountered in /in/GVNsR on line 24 Warning: A non-numeric value encountered in /in/GVNsR on line 24 Warning: A non-numeric value encountered in /in/GVNsR on line 24 second
Output for 5.4.9 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.21, 7.0.0 - 7.0.20
first second first second second

preferences:
161.26 ms | 402 KiB | 218 Q