How to verify if $_GET exists?

前端 未结 7 1961
生来不讨喜
生来不讨喜 2020-12-02 21:59

So, I have some PHP code that looks a bit like this:


    The ID is 

    


         


        
7条回答
  •  星月不相逢
    2020-12-02 22:47

    Normally it is quite good to do:

    echo isset($_GET['id']) ? $_GET['id'] : 'wtf';
    

    This is so when assigning the var to other variables you can do defaults all in one breath instead of constantly using if statements to just give them a default value if they are not set.

提交回复
热议问题