PHP比较的这个逻辑有什么错误


what is the mistake in this logic for php comparison?

当我给

 <? echo $submissiontype ?>

我得到的输出为

  PRIORITY 

但是对于下面的代码,我希望输出为

 selected

但我无法得到它,

<? if($submissiontype == 'PRIORITY') {echo 'selected';} ?>

上面的代码有什么错误?

如果先修剪$submissionType类型怎么办。

<? if(trim($submissiontype) == 'PRIORITY') {echo 'selected';} ?>

通常有一些我们没有考虑的空格。

你也可以使用string compare, strcmp

if(!strcmp($submissiontype," PRIORITY")) {
echo "selected";
}