syntax error, unexpected identifier “%s”, expecting “(”¶
Description¶
After the function keyword and the function’s name, PHP expects the opening parenthesis of the argument list. Here, a second identifier was found instead, which usually means an extra word was typed, or a comma or a return-type colon was forgotten between two declarations.
Example¶
<?php
function foo bar() {}
?>
Literal Examples¶
syntax error, unexpected identifier “bar”, expecting “(”
Solutions¶
Remove the extra identifier, keeping only the function name.
If a return type was intended, add a colon before it:
function foo(): bar {}.If two functions were meant to be declared, close the first one and start a new
functionstatement.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.