if条件有什么错误?

时间:2015-10-30 16:46:39

标签: php

echo $approver;输出&#34;主管&#34;在网页上,但代码echo "Supervisor is working <br />"不会输出任何内容。

$approver = $_POST['approver'];

echo $approver; 
echo "<br />";

//echo "It is working <br />";
if ($approver == "Supervisor")
    echo "Supervisor is working <br />";

1 个答案:

答案 0 :(得分:3)

$_POST["approver"]字符串中有一些空格很可能。为避免这种情况,请尝试更改:

$approver = $_POST['approver'];

为:

$approver = trim($_POST['approver']);