PHP Error – Parse error: syntax error, unexpected $end in

by damonp on February 23, 2007

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.

[root@atlas ~]# php -i | grep short_open_tag
105:short_open_tag => On => On

Create .htaccess file:

php_flag short_open_tag on

Page loads with no errors.

Do a search for short open PHP tags in the source and replace with default tags.

Find

<?

Replace

<?php

Turn short_open_tag back off in .htacess:

php_flag short_open_tag off

Page still loads with no errors.

Popularity: 39% [?]

{ 2 comments… read them below or add one }

zeyad shorman March 4, 2009 at 3:59 pm

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;
?>

Reply

zeyad shorman March 4, 2009 at 4:01 pm

this one $x $y = $sum
$x – $y = $dif
$x * $y = $prod
$x / $y =$quotient
HERE;
?>

Reply

Leave a Comment

Previous post:

Next post: