PHP if else
Last Updated: July 31, 2021
if
statement can be used to do a logical comparison.
Simple if
statement
if($number > 10){
echo "number is greater than 10";
}
If
statement with two conditions
if($number > 10 ){
echo "number is greater than 10";
}
Inline if statement or PHP Shorthand If/Else Using Ternary Operators (?:)
( $post_id == $post4->ID)? 'active' :''
This is very useful when you want to show some data on HTML pages