I have an if statement, which ideally I'd like to check the value of a variable, only if the variable exists. My if statement looks something like this:
if( variable_1 == "value_1" &
variable_2 == "value_2"){
// code to execute
}
however, sometimes variable_2 won't have been defined, and so the code crashes when that happens. Is there an elegant way to check if variable_2 exists, and if it does exist check what its value is?
Thanks is advance! Apologies if I've overlooked something basic.
Aucun commentaire:
Enregistrer un commentaire