这段代码是什么?我得到Parse错误:语法错误,意外'。'

时间:2014-01-19 09:20:52

标签: php

我得到Parse error: syntax error, unexpected '.'我无法弄清楚这段代码有什么问题。请帮助

我的代码

<?php
session_start();
if(isset($_SESSION['SESS_CHANGEID']) == TRUE) {
session_unset();
session_regenerate_id();
}
require("config.php");
?>

<?php echo $config_sitename; ?>
<div id="header"></div>
<div id="menu">
<a href="<?php echo $config_basedir; ?>">Home</a> -

<a href="<?php echo $config_basedir;?>showcart.php">View Basket/Checkout</a></div>
<div id="container">
<div id="bar">
<?php
require("bar.php");

echo "<hr />";

if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE)
{
echo "Logged in as <strong>" . $_SESSION['SESS_USERNAME'] . "</strong>[<a href="&quot; . $config_basedir. &quot;logout.php>"logout</a>]";
}
else
{
echo "<a href="&quot;. $config_basedir . &quot;login.php">Login</a>";
}
?>

提前致谢。

5 个答案:

答案 0 :(得分:2)

echo "<a href="&quot;. $config_basedir . &quot;login.php">Login</a>";

替换为:

echo "<a href='".$config_basedir."login.php'>Login</a>";

答案 1 :(得分:0)

这一行

echo "<a href="&quot;. $config_basedir 

修正报价

echo "<a href=&quot;". $config_basedir 

答案 2 :(得分:0)

替换此&quot;问题的原因。

    if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE)
    {
    echo "Logged in as <strong>" . $_SESSION['SESS_USERNAME'] . "</strong>[<a href='" . $config_basedir."'logout.php>logout</a>]";
    }
    else
    {
    echo "<a href='". $config_basedir ."'login.php>Login</a>";
    }

答案 3 :(得分:0)

这是固定代码。我建议使用带语法高亮的IDE。即PhpStorm。     

<?php echo $config_sitename; ?>
    <div id="header"></div>
    <div id="menu">
        <a href="<?php echo $config_basedir; ?>">Home</a> -

        <a href="<?php echo $config_basedir;?>showcart.php">View Basket/Checkout</a></div>
    <div id="container">
        <div id="bar">
<?php
require("bar.php");

echo "<hr />";

if(isset($_SESSION['SESS_LOGGEDIN']) == TRUE)
{
    echo "Logged in as <strong>" . $_SESSION['SESS_USERNAME'] . "</strong>[<a href=\"&quot;" . $config_basedir. "&quot;logout.php>\"logout</a>]";
}
else
{
    echo "<a href=\"&quot; ". $config_basedir . "&quot;login.php\">Login</a>";
}
?>

答案 4 :(得分:0)

提示:不要在双引号内包含双引号或在单引号内包含单引号 但是包括double和single and inverse。

In this line `echo "Logged in as <strong>" . $_SESSION['SESS_USERNAME'] . "</strong>[<a href="&quot; . $config_basedir. &quot;logout.php>"logout</a>]";

`
Just replace "&quot; with '&quot;
and replace "logout with 'logout

and in this line `echo "<a href="&quot;. $config_basedir . &quot;login.php">Login</a>";
`

Just replace "&quot; with '&quot;
and replace login.php" with login.php'