意外的T_VARIABLE,但它';It’这并不意外


Unexpected T_VARIABLE, but it's not unexpected

我得到一个错误:

分析错误:语法错误,第4行上home2/chippery/public_html/login/text/loginStuff.php中出现意外T_VARIABLE

第4行:

$pass=$_POST['password']

然而,3号线运行良好:

$user=$_POST['username']

帖子来自:

<html>
<form action='loginStuff.php' method='POST'>
User: <input type='text' name='username'><br>
Pass: <input type='password' name='password'><br>
<input type='submit' value='Log In'>
</form>
</html>

刚刚进入PHP(不到一个小时前),所以我确信这是一个愚蠢的错误,但你能找出问题所在吗?

每行末尾都需要一个分号。

用分号; 结束条件/变量分配/操作

示例:

$Username = $_POST['Username']; // Solution
$Password = $_POST['Password']; // Solution
$Username = trim($_POST['Username']); // Example only 

但不适用于if语句:

if (isset($_POST['Username'])){
   if (isset($_POST['Username'])){
     $Username = $_POST['Username'];
   }
} // No semi colon needed here, only inside the braces