Parse error: syntax error, unexpected $end in … on line …
Don’t you love it when the line number indicated for an error message is the last line in the file which obviously has no error? I spent twenty minutes on this one last night.
Check for unmatched braces, brackets, parentheses or PHP tags. Nope.
Try echoing line numbers to see where execution stops. In this case no output was generated even with an echo on line #1.
Create a new file and pasted the code as Unix ASCII. Still no change.
Check PHP settings. short_open_tag is disabled by default.
105:short_open_tag => On => On
Create .htaccess file:
Page loads with no errors.
Do a search for short open PHP tags in the source and replace with default tags.
Find
Replace
Turn short_open_tag back off in .htacess:
Page still loads with no errors.
Popularity: 35%
{ 6 comments… read them below or add one }
i have error on my php code ,the error is Parse error: syntax error, unexpected $end in E:\AppServ\www\constant.php on line 17
Three plus five
three plus five
demonstrate use of number variables
$x $y = $sum
$x – $y = $dif
$x * $y = $prod
$x / $y = $quotient
HERE;
?>
this one $x $y = $sum
$x – $y = $dif
$x * $y = $prod
$x / $y =$quotient
HERE;
?>
1. $page .= <<<EOD
2. © $year $copyright
3.
4.
5. EOD;
6. return $page;
see to that you have no spaces between line 1&2 also bet line 5 & 6. This would resolve the error. for eg: go to line 1 hit del key until u have no space between EOD(of line 1) and <(of line 2) then hit enter
}
Once it happened that everything was fine but I was getting this error. It made me mad, but then at the end, the error was something to laugh about. I was using cuteFTP and uploading files to 000webhost, it so happened that the file transfer terminated somewhere in the middle, such that whole file was not transfered and the file containing missing code, was up on the server, that;s where the error was coming.
beat my head up against this for a day. it works on my production server, but failed on my testing server. I simply could NOT figure it out. turns out it was in fact the short opening PHP tags.
thanks…
thanx , realy thanx, it solved my problem . my setup is wamp with joomla 1.7
and i when to php->php settings->open tag tag must be ticked