Category — php
Parse error: syntax error, unexpected $end in Command line code
this is very strange error on PHP, i’ve using php since 2005 and never got this error, but yesterday after installing xampp on my laptop and try to put my website project on it, i got this error.
Parse error: syntax error, unexpected $end in Command line code
it’s strange because on the another machine my code run well, so i got stuck for a few days, but of course i still curious why i got an error while it’s run well on other machine.
the answer is on our php tag, this what i got from google
Situations:
* you forgot to close a quote, so PHP is continuing to analyze your code until it finds the closing quotation mark.
* You forgot to close a bracket, so from the last opening, Php considers all the code that follows as part of a block that never ends.
* You forgot to close a parenthesis, so from the last open parenthesis, Php considers all the code that follows as part of a specific block (condition, arguments of functions etc …) that does not end.
* You forgot a comma, so for PHP there is an instruction in your code that has no end.
of course i do checked my code and pretty sure that i ain’t forgot anything, but the answer is we sometime using a sort open tag, what i mean is it’s like open and end php tag just using <?…?> well,a solution of course replacing <? with <?php makes the problem go away. but i have another solution for this Parse error: syntax error, unexpected $end in Command line code problem.
we can turn on short open tag on PHP, to use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On
enjoy
March 28, 2010 No Comments