PHP if ... else ...语句返回错误

时间:2013-02-27 01:28:19

标签: php if-statement

以下是我的代码

        <?php
//Vars
$alreadylogged = 0;
$username = 0;
//End Var
//Start Script
print 'Welcome to CraftedList!</br>'
if ($alreadylogged=="1") *Side note, this line is line 34*
{
    print 'You are currently logged in as'. $username .'!';
}
else
{
    print 'You are not logged in!'
}
    ?>

但是当我在localhost XAMPP客户端上执行它时,它会返回此错误。

  

解析错误:语法错误,第34行的C:\ xampp \ htdocs \ phptest \ index.php中的意外'if'(T_IF)

我检查了W3学校,我的代码与他们的代码类似。

2 个答案:

答案 0 :(得分:6)

您错过了;

print 'Welcome to CraftedList!</br>';
                                    ^ here

答案 1 :(得分:2)

缺少;

这里:

print 'Welcome to CraftedList!</br>'

在这里:

print 'You are not logged in!'