答案 0 :(得分:3)
变化:
$value= isset($students[$var1][$var2]) ? $students[$var1][$var2] : '';
if ($value <> '')
要:
$value = isset($students[$var1][$var2]) ? $students[$var1][$var2] : false;
if ($value !== false)
当然还有其他方法可以做到这一点。想要避免比较零和空字符串的底线,它们将被评估为相同。而是使用===
和!==
进行精确比较。
请点击此处了解详情:http://nl1.php.net/manual/en/language.operators.comparison.php
答案 1 :(得分:0)
使用此运算符(不相同,它也将检查变量的类型):
type juggling
由于{{1}}™,您遇到了问题,如下所述:http://php.net/manual/en/language.operators.comparison.php