简体   繁体   English

通知 php - 替代或删除?

[英]notice php - alternative or remove?

i am using this code to check if the variables $n0, $n1, $n2 are not defined.我正在使用此代码检查变量$n0, $n1, $n2是否未定义。

But i get a notice each time that was not defined.但是每次我都会收到未定义的通知。 My code is a bad practice?我的代码是一个不好的做法? there is any alternative?有什么选择吗? or just remove the notices and the code is fine?或者只是删除通知并且代码很好?

            if (!isset ($n0) && $n0 != $form['name0']){
                echo ("n0");
            }

            if (!isset ($n1) && $n1 != $form['name1']) {
                echo ("n1");
            }

            if (!isset ($n2) && $n2 != $form['name2']) {
                echo ("n2");
            }

thanks谢谢

You should actually be replacing those && 's with ||您实际上应该将那些&&替换为|| 's.的。 If the $n 's aren't set then they surely won't equal the $form values..如果未设置$n ,那么它们肯定不会等于$form值。

This will prevent the notices and do what you're intending这将阻止通知并执行您想要的操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM