match Is Now A Keyword¶
Match() was introduced in PHP 8.0 as a new command. As a side effect, it is now a PHP keyword, and it is not possible to create classes, functions or constants with that name.
PHP code¶
<?php
function match() {
echo __FUNCTION__;
}
match();
?>
Before¶
match
After¶
PHP Parse error: syntax error, unexpected token "match", expecting "(" in /codes/matchKeyword.php on line 3
Parse error: syntax error, unexpected token "match", expecting "(" in /codes/matchKeyword.php on line 3
PHP version change¶
This behavior changed in 8.0