syntax error, unexpected token “::”, expecting “:”¶
Description¶
In this example, Match
is a PHP keyword, and cannot be part of a static call, with the operator ::
. On the other hand, Match
could be a parameter name, where the foo
function, has a $Match
parameter. Hence, the suggestion to use :
a single colon.
This error may also appear with other keywords, such as Switch
. It is also case-insensitive.
Example¶
<?php
foo(Match::a());
?>
Solutions¶
Use a single colon, if
$Match
is actually a parameter name.Rename the
Match
class to avoid conflicts with PHP keywords.