Very quickly upon diving into the world of programming you’ll discover than conditions and logical arguments are essential to the majority of tasks you’ll do. One of the very first things you’ll come across is the If / Else statement. An example would be “If user is admin display post statistics else display advert”. A simple premise, but can be be tailored to be used in countless situations. Here’s a coded example:

$number = 10;
$is_number_greater_than_8 = if($number > 8) {true;} else {false;}

That’s the way I typically do it! However there is a shorthand way! Here goes:

$number = 10;
$is_number_greater_than_8 = ($number > 8 ? true : false); 
// returns true

Leave a Reply