我有这段代码:
<?php unless($category['name'] == "Offer") { ?>
<p>Write this unless category name equal "Offer"</p>
<?php } ?>
我知道这是错误的,你如何在PHP中创建一个除非语句,就像在Rails中一样?
答案 0 :(得分:3)
使用不等于!=
运算符
if($category['name'] != "Offer") {
//Process here
}
答案 1 :(得分:2)
<?php if ($category['name'] != "Offer") { ?>
<p>Write this unless category name equal "Offer"</p>
<?php } ?>