如何修复代码中的Undefined变量?

时间:2017-04-17 19:53:30

标签: php

                if($generator == "" || $_SESSION['rank'] == 5){
                    $generatorquery = "SELECT * FROM `generators`";
                }else{
                    $generatorquery = "SELECT * FROM `generators` WHERE `id` = ".$generator;
                }

如何修复第一行代码?

1 个答案:

答案 0 :(得分:0)

如果我说得对,如果你想检查变量“generator”是否为空(它有一个值)那么这对你有用:

 if(empty($generator) || $_SESSION['rank'] == 5)