这是我的代码:
<html>
<head>
<title>
</title>
</head>
<body>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if (($username=="x")AND($password=="y"))
{
echo "You are logged in as".$username.";
}
?>
</body>
</html>
我得到一个解析错误:
解析错误:语法错误,意外的文件结束,期望变量 (T_VARIABLE)或$ {(T_DOLLAR_OPEN_CURLY_BRACES)或{$(T_CURLY_OPEN) 第17行
答案 0 :(得分:5)
答案 1 :(得分:2)
您要么错过"
,要么还有一个"
echo "You are logged in as".$username.";
可以成为
echo "You are logged in as".$username."";
或
echo "You are logged in as".$username;
甚至更好的解决方案:
echo "You are logged in as {$username}";
为了更好地阅读您的代码,请不要使用AND
,请使用&&
答案 2 :(得分:0)
这是完全固定的代码。
<html>
<head>
<title>
</title>
</head>
<body>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if (($username=="x")AND($password=="y"))
{
echo "You are logged in as".$username;
}
?>
</body>
</html>
答案 3 :(得分:0)
双引号("
)问题:
echo "You are logged in as".$username.";
你可以这样做:
echo "You are logged in as {$username}";