- Web templates
- E-commerce Templates
- CMS & Blog Templates
- Facebook Templates
- Website Builders
if…else
March 18, 2016
Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do this.
The if….else statement executes some code if a condition is true and another code if that condition is false.
The if….else syntaxt in PHP is similar to the one in JavaScript and any other C-like language.
if (condition) { code to be executed if condition is true; } else { code to be executed if condition is false; }
The condition can be any expression that result into a boolean value (true or false), for example:
if ($number_of_posts > 9) { show_breadcrumbs(); }