syntax error, unexpected identifier “%s”¶
Description¶
This error appears when two identifiers are following each other. This is usually rooted in a missing keyword or character.
Named structures usually start with a keyword, such as class, interface, function, etc.
In a function call, a missing opening parenthesis brings the named parameter and the function name together.
The error also appears when new lines are used inside a namespace. This was valid until PHP 8.0, but is not anymore.
Example¶
<?php
// missing keyword: class, or interface
A extends B {}
// missing opening parenthesis
foo name:1);
// new lines in namespace
echo \A
B\
C;
?>
Literal Examples¶
syntax error, unexpected identifier “A”
Solutions¶
Add the missing keyword before the identifier.
Add a missing opening parenthesis to the function call.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See MultilineQualifiedName.