所以我在 PHP 中有这段代码,但由于某些我不知道的原因它无法工作:
if(!empty($ccle))
{
header("Location: http://google.com");
}
else
{
header("Location: http://yahoo.com");
}
我想要的是:如果“ccle”字段为空,则转到 google.com 或者,如果“ccle”字段不为空(值在哪里),则转到 yahoo.com
如何让它做到这一点?
最佳答案
你需要切换它们...
if(!empty($ccle))
{
// Go to Yahoo if $ccle is NOT empty
header("Location: http://yahoo.com");
}
else
{
// Else, go to Google
header("Location: http://google.com");
}
只是详细说明。你的 if
语句说的是......
if($ccle IS NOT empty)
PHP 中的感叹号是逻辑非 运算符。
关于php - 如何检查字段是否为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16095580/