I am getting the following error in one of my php file Parse error: syntax error, unexpected $end in /home/qualitet/public_html/game/crea开发者_如何学编程te.php on line 1
What could be the problem? I checked all the if else.
The parser encountered an unexpected end of your source code. So you’re probably missing some closing curly bracket or something similar.
I checked all the if else.
I don't think you did :) Try commenting out all of them, and bringing them back one at a time.
Check if all your curly braces are closed. It can also be caused by short open tags
You've probably missed a closing bracket (}
) somewhere.
I use a binary search to find this.
Save your file to a new file and then remove large chunks (1/2) at a time, until the code compiles. That last chunk removed is the one with the missing }
I thought I also add to this ticket, since I've had a similar problem and there wasn't anything visible that could cause it, however after calling one of the methods after instantiation of the class there was an invisible character a after closing semicolon, which was causing the same error - once I've removed semicolon and everything after it, then put the semicolon back - everything started working fine.
You might need to check whether you have short codes turned on <?
as some plugins or themes use them and your development settings in php.ini might have them disabled.
Production
short_open_tag = On
Development
short_open_tag = Off
See the PHP manual for more info regarding use of <?
and <?php
This often explains why local development server operation differs from live server due to PHP configuration differences.
精彩评论