phpstorm warning php variable might not have been defined

前端 未结 2 1925
天涯浪人
天涯浪人 2020-12-09 13:59


        
2条回答
  •  醉话见心
    2020-12-09 14:15

    Yeah, there's two things you can do to get rid of this warning. What you said:

    $smith = "";
    if($submit == "button_a") {
        $smith = "button_a";
    }
    elseif($submit == "button_b"){
        $smith = "button_b";
    }
    

    Or check if it's set when you print it:

    
    

    However, this is just a warning, and it is letting you know that there is a condition that $smith won't be defined (when $submit isn't "button_a" and isn't "button_b"). If that condition were to occur, you would be printing $smith when it wasn't set, which could be a bug in your script.

提交回复
热议问题