In PHP, you can include one if
statement inside another, forming a “nested if” structure. This is particularly useful when you need to evaluate multiple related conditions.
Example
Consider a scenario where you want to check the engine power of a motorcycle. If its horsepower exceeds 100, it will further check if it exceeds 150 and output messages accordingly:
$horsepower = 130; // Horsepower of the motorcycle if ($horsepower > 100) { echo "Powerful engine"; if ($horsepower > 150) { echo " and exceptionally high performance!"; } else { echo " but not a superbike-level engine."; } }