3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($f) { try { $f(); echo "No error?\n"; } catch (TypeError|ValueError $e) { if (strpos($e->getMessage(), '($WRONG_SCOPE_')) { echo "Bad error! ", $e->getMessage(), "\n"; } else { echo "Good error.\n"; } } } test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < "x"); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) < []); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + "x"); test(fn($WRONG_SCOPE_1 = 0, $WRONG_SCOPE_2 = 0) => gmp_init(1) + []);
Output for 8.0.8 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Good error. Good error. Good error. Good error.
Output for 7.4.26, 7.4.33, 8.0.13
Fatal error: Uncaught Error: Call to undefined function gmp_init() in /in/J00BTp:15 Stack trace: #0 /in/J00BTp(5): {closure}() #1 /in/J00BTp(15): test(Object(Closure)) #2 {main} thrown in /in/J00BTp on line 15
Process exited with code 255.
Output for 8.0.0 - 8.0.7
Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) is not an integer string Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) must be of type GMP|string|int, array given Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) is not an integer string Bad error! {closure}(): Argument #2 ($WRONG_SCOPE_2) must be of type GMP|string|int, array given
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
Warning: {closure}(): Unable to convert variable to GMP - string is not an integer in /in/J00BTp on line 15 No error? Warning: {closure}(): Unable to convert variable to GMP - wrong type in /in/J00BTp on line 16 No error? Warning: {closure}(): Unable to convert variable to GMP - string is not an integer in /in/J00BTp on line 17 No error? Warning: {closure}(): Unable to convert variable to GMP - wrong type in /in/J00BTp on line 18 No error?
Output for 7.3.0 - 7.3.33
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in /in/J00BTp on line 15
Process exited with code 255.

preferences:
158.55 ms | 401 KiB | 150 Q