Parse error: Syntax error, unexpected end of file in my PHP code
I got an error:
Parse error: syntax error, unexpected end of file in the line
With this code:
<html>
<?php
function login()
{
// Login function code
}
if (login())
{?>
<h2>Welcome Administrator</h2>
<a href="upload.php">Upload Files</a>
<br />
<a href="points.php">Edit Points Tally</a>
<?php}
else
{
echo "Incorrect login details. Please login";
}
?>
Some more HTML code
</html>
What's the problem?
You should avoid this (at the end of your code):
{?>
and this:
<?php}
You shouldn't put brackets directly close to the open/close php
tag, but it separate with a space:
{ ?>
<?php {
also avoid <?
and use <?php
I had the same error, but I had it fixed by modifying the php.ini
file.
Find your php.ini file see Dude, where's my php.ini?
then open it with your favorite editor.
Look for a short_open_tag
property, and apply the following change:
; short_open_tag = Off ; previous value
short_open_tag = On ; new value
I had the same error, but I had it fixed by modifying the php.ini and / or editing the PHP file!
There are two different methods to get around the parse error syntax.
Method 1 (Your PHP file)
Avoid in your PHP file this:
<? } ?>
Make sure you put it like this
<?php ?>
Your code contains <? ?>
<? ?>
NOTE: The missing php
after <?
!
Method 1 (php.ini file)
There is also a simple way to solve your problem. Search for the short_open_tag
property value (Use in your text editor with Ctrl + F
!), and apply the following change:
; short_open_tag = Off
to
short_open_tag = On
NOTE: Reload your Server (like for example: Apache) and reload your PHP webpage in your browser.
链接地址: http://www.djcxy.com/p/11874.html上一篇: 解析错误:语法错误,中意外的'<'