Last Updated on 2021-12-30 by Clay
Today when I developed a WordPress plugin, the menu program encountered the following syntax parse error message:
Parse error: syntax error, unexpected ''lists_page'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in /var/www/html/wp-content/plugins/reserve-course/reserve-course.php on line 54
This is a very common error in PHP, as the error message shows, it is a parse error and syntax error. If you incorrect use of single quotes and double quotes or even a mixture of them may cause such errors to occur, sometimes even one missing comma ,
can cause such an error.
Solution
The most common error situation is:
echo 'this is a 'good website'';
We need to change it to:
echo 'this is a "good website"';
or use the escape symbol \
:
echo 'this is a \'good website\'';
And don't forget to check if you have added commas between all parameters and semicolons for code paragraphs.
References
- https://stackoverflow.com/questions/25263975/unexpected-t-constant-encapsed-string-expecting-or
- https://wordpress.stackexchange.com/questions/242073/unexpected-t-constant-encapsed-string-expecting-in-widget