Leave a Reply

2 Comments on "PHP Basics: The ternary operator (30/35)"

Notify of
avatar

Trotsky Grip
Guest
Trotsky Grip
8 months 9 days ago
I don't know if I am missing a step, I am a complete php noob, but I am really not understanding why we need to do what you are showing in this video. You say at the beginning that "we ran into the problem where we need to check if something is set in case we run into any problems." can someone explain what problems are being referred to. Admittedly I do not know that much about query strings, this may be an understatement and it is something I will look into, but I don't get what problem we are… Read more »
Ahmed Eid
Guest
Ahmed Eid
7 months 8 days ago

he meant it would break the functionality of your page , what would you do if use has erased the query string for some reason so .. hes trying to demonstrate how elegant it is to use the ternary operator (condition?true:false) to set default values , you could use if else but ternary is much less code .

wpDiscuz