PHP: Check if variable exist but also if has a value equal to something

前端 未结 13 1782
抹茶落季
抹茶落季 2020-12-01 13:46

I have (or not) a variable $_GET[\'myvar\'] coming from my query string and I want to check if this variable exists and also if the value corresponds to somethi

13条回答
  •  感情败类
    2020-12-01 14:23

    Well, you could get by with just if($_GET['myvar'] == 'something') since that condition presumes that the variable also exists. If it doesn't, the expression will also result in false.

    I think it's ok to do this inside conditional statements like above. No harm done really.

提交回复
热议问题