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

OPa*_*tel 0 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!'
}
    ?>
Run Code Online (Sandbox Code Playgroud)

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

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

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

jer*_*oen 6

你错过了一个 ;

print 'Welcome to CraftedList!</br>';
                                    ^ here
Run Code Online (Sandbox Code Playgroud)

  • @ user1185220在'print'上也缺少分号你没有登录!''行. (2认同)