lundi 13 juin 2016

Run code only if IF and ELSEIF Statement Run

$Variable = "Dog"

if($Variable == "Cat"){
     do stuff
}
elseif($Variable == "Goat"){
     do other stuff
}
elseif($Variable == "Cash"){
     Run some other stuff
}

How would I write code to say echo "hi" if and only if one of the statements were true? My Question is do I have to write echo "hi" inside each statement? or can I save lines by doing it a certain way?

Aucun commentaire:

Enregistrer un commentaire