-3

我正在尝试添加一个“if and”语句,但无法使其正常工作。

else if($iamonly == 'Other - ' && trim($othertype == '')) {
    echo '<div class="error_message">Error! You selected "Other"</div>';

如果$iamonly字段是“其他”并且我在$othertype字段中输入数据,我仍然会收到错误消息。请有人能告诉我我在这里做错了什么。

4

2 回答 2

3

trim只有变量:

if($iamonly == 'Other - ' && trim($othertype) == '') {
于 2012-09-07T08:42:19.620 回答
2

这个:

else if($iamonly == 'Other - ' && trim($othertype == '')) {
    echo '<div class="error_message">Error! You selected "Other"</div>';

应该是这样的:

else if($iamonly == 'Other - ' && trim($othertype) == '') {
    echo '<div class="error_message">Error! You selected "Other"</div>';
于 2012-09-07T08:42:11.230 回答