【问题标题】:Why am I getting this parse error in a PHP if statement? [closed]为什么我在 PHP if 语句中收到此解析错误? [关闭]
【发布时间】:2014-02-15 16:00:24
【问题描述】:

我收到此错误:

解析错误:语法错误,第 131 行 C:\xampp\htdocs\assurance\confirmation.php 中出现意外的 '!=' (T_IS_NOT_EQUAL)

这是我的代码的第 131-134 行:

if ($_POST['password']) != ($_POST['confirm'])  { 
echo '<p class="error">Your passwords do not match.</p>';
$okay = FALSE;
}

【问题讨论】:

  • 去掉多余的括号。你的代码应该是:if ($_POST['password'] != $_POST['confirm']).
  • if ($_POST['password'] != $_POST['confirm'])
  • 要求代码的问题必须表明对所解决问题的最低理解。包括尝试过的解决方案、它们为什么不起作用以及预期的结果。

标签: php parse-error control-structure


【解决方案1】:
if ($_POST['password'] != $_POST['confirm'])  { 
echo '<p class="error">Your passwords do not match.</p>';
$okay = FALSE;
}

if 语句的语法是

if (expr)
  statement

http://www.php.net/manual/en/control-structures.if.php

【讨论】:

    【解决方案2】:

    使用这个

    if ($_POST['password'] != $_POST['confirm'])  { 
        echo '<p class="error">Your passwords do not match.</p>';
        $okay = FALSE;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多