无法理解为什么php给我这个错误

时间:2014-02-24 15:16:10

标签: php

我的php脚本给了我这个错误,不知道发生了什么: Parse error: syntax error, unexpected '<' in /home/u381071273/public_html/upload/myfiles.php on line 8,以下是我用来查看登录用户内容的代码

php code

<?php
include('models/db-settings.php');
include('models/config.php');
include('models/header.php');
$uplfolder = $_REQUEST['folder']; //The folder required by the user.
?>
<?php if(isUserLoggedIn()) { 
<div id='main' role='main'>
                <div id='blocks'>
            <ul class='grid'>
<?php
include 'models/viewdir.php'; //This script opens the user's folders.
?>
            </ul></div>
        </div>
    </body>
}
else
{

}
?>

3 个答案:

答案 0 :(得分:3)

将第8行更改为

<?php if(isUserLoggedIn()) {  ?>

在开始HTML输出之前,您没有关闭PHP

对于第21行:

    </body>
<?php }

答案 1 :(得分:0)

<?php
include('models/db-settings.php');
include('models/config.php');
include('models/header.php');
$uplfolder = $_REQUEST['folder']; //The folder required by the user.
?>
<?php if(isUserLoggedIn()) { ?>
<div id='main' role='main'>
            <div id='blocks'>
        <ul class='grid'>
<?php
include 'models/viewdir.php'; //This script opens the user's folders.
?>
        </ul></div>
    </div>
</body>

//next error will be here
<?php
}
else
{

}
?>

答案 2 :(得分:0)

代码问题是你没有从php

中正确地转义html部分

您的密码:

<?php
include('models/db-settings.php');
include('models/config.php');
include('models/header.php');
$uplfolder = $_REQUEST['folder']; //The folder required by the user.
?>
<?php if(isUserLoggedIn()) { 
<div id='main' role='main'>
                <div id='blocks'>
            <ul class='grid'>
<?php
include 'models/viewdir.php'; //This script opens the user's folders.
?>
            </ul></div>
        </div>
    </body>
}
else
{

}
?>

将其更改为:

<?php
include('models/db-settings.php');
include('models/config.php');
include('models/header.php');
$uplfolder = $_REQUEST['folder']; //The folder required by the user.
?>
<?php if(isUserLoggedIn()) { ?>
<div id='main' role='main'>
                <div id='blocks'>
            <ul class='grid'>
<?php
include 'models/viewdir.php'; //This script opens the user's folders.
?>
            </ul></div>
        </div>
    </body>
<?php
}
else
{

}
?>