PHP Parse Error: syntax error, unexpected $end
In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:
Parse Error: syntax error, unexpected $end in ….. scripts.php on line …
The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.
But more commonly, the error is often caused by the use of Short Open tags in PHP, instead of full tag,
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
Related Articles
- Robocopy Syntax, Command Line Switches and Examples
- PHP Allowed Memory Size Exchausted Fatal Error
- Internal Error 2739 Error in Vista (32 or 64-bit) When Install Adobe Photoshop CS3 and Reflector Related Programs
- Failed or Missing Dependency of glibc-common Error
- WordPress MySQL SQL Query Error in WPDB Class
- Fix Internal Server Error When Accessing Easy Apache in cPanel WebHosting Manager
- PHP Scripts open_basedir Restriction in Effect Error
- Oracle Database Import Error 3113/3114
- Gmail Email Message Corrupted Error
- Spb Finance Synchronization Error in Microsoft ActiveSync










































October 29th, 2009 22:19
3 years later, I found the real problem. Somewhere in the code is written %>, like in a table .
If your asp_tags = On, in ASP it means closing. It’s amongst your HTML code. I got many hours to solve this problem.
October 3rd, 2009 17:59
Thanks Buddy your information helped me from hell of headache(spcly whn the code is not written by youself and u have to make your changes into it..phewww)….but thanks your suggestions helped me to locate and remove errors…..making <? to <?php solved my prob..:)
July 9th, 2009 14:15
Also, some Webserver does not support the tag <? for php files, change them to <?php and it can work. (Dar Es Salaam, Tanzania)
January 25th, 2009 12:42
It was very much helpful in solving my problem of the same kind of error.
December 11th, 2008 11:26
Thank you for this awesome tip about short_open_tags! Would have never found that by myself.
September 12th, 2008 23:57
Rana, any source code editor that supports Find / Replace with Regular Expressions can help you balance braces.
Example: in Macrodobe Dreamweaver (any non-absolutely-ancient version), do [Ctrl]+[F] to activate Find/Replace, tell it:
Find in: Current Document
Search: Source Code
Find: [{}]
Replace: (leave blank)
Options: “Use Regular Expression” checked, all others unchecked.
Then simply do Find Next. This will find both opening and closing braces. For each opening brace you find, count them starting at 1. For each closing brace, subtract 1 from the current count. You should wind up at 0 just before it wraps around back to the beginning (also in any specific function, block, etc.).
E.g.
foreach ($array as $value) { // 1if ($value > 100) { // 2
echo "$value too big!\n";
} // 1
} // 0
May 10th, 2008 14:10
Thank you very much …..
March 17th, 2008 00:32
Thank you,
Been searching for ages for solution to this.
short_open_tag = On solved that problem for me.
Finally I can open templates
March 8th, 2008 14:27
syntax error, unexpected $end in C:\wamp\www\login.php on line 49
February 27th, 2008 20:22
Thanks for your time, But for me Its really didfficult to find a missing curly bracket.
Is there any easiest way to findout with MISSING CURLY BRACKET. Any editor can do it for us.
Please Help.
Rana
October 23rd, 2007 18:52
Very useful, thanks. I just upgraded to openSuse 10.3 from 10.2 which had reset my php.ini.
September 30th, 2007 12:07
wow! thanks for your useful guidance…
September 15th, 2007 20:20
thhanx a lot short_open_tag = On solved my problem. ypu are helpful
August 30th, 2007 19:39
Thanks a ton, I’ve been trying to figure this out for the last few hours.
March 29th, 2007 22:29
This might be due to a missing quote also
February 5th, 2007 07:41
Hello. I have a problem with a PHP file that shows the “PHP Parse Error: syntax error, unexpected $end” error and I followed the instructions in this page and corrected the php.ini from OFF to ON.
Now, the file don’t give any feedback when I open it. It only gives me a blank page and no info! O_o
It’s strange… Can you help me please? Thanks.
December 20th, 2006 04:57
I saw your posting and made the change to the php.ini file and I’m still getting the error the is being run with Fedora Core 5 with MySql 5.
Can someone please help
0)
{
while ($row = mysql_fetch_assoc($result))
{
print $row(’cust_id’) . ‘-’ . $row(’cust_url_desc’) ;
}
}
else
{
echo ‘No rows found!’;
}
mysql_free_result($result);
mysql_close($connection);
?>
August 22nd, 2006 22:49
Thanks for this post…saved me a lot of time!
May 14th, 2006 23:30
thanks a lot,
short_open_tag = On solved that problem for me