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.10, 8.1rc1
Good error. Good error. Good error. Good error.
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.23
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.30
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in /in/J00BTp on line 15
Process exited with code 255.

preferences:
45.27 ms | 463 KiB | 5 Q