syntax error, unexpected token “:”¶
Description¶
A syntax error is a generic error, where PHP could not compile the code. Here are some classic typo or seemingly valid code that leads to this error.
Since PHP 8.0, named parameters may be used, though parameters don’t use the initial
$
sign.
Example¶
<?php
// calling a named parameter, with the $ in the parameter name
foo($c: 1);
?>
Solutions¶
Fix the name of the parameter.