syntax error, unexpected ‘-’, expecting ‘=’¶
Description¶
When defining a constant, the constant name must be valid. It must be satisfying the following regex: /[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/
. When an unexpected character appears, it yields this errors, mentioning the erroneous character first.
This error appears for global constant, written with const
or for class constants, inside a class.
The unexpected character may have a lot of variations, in particular any non-letter or non-figure characters. Check the regex for more options.
Example¶
<?php
const A-B = 1;
?>
Solutions¶
Remove the
-
in the constant name.Remove the
unexpected
character in the constant name.Remove the constant definition.