It is a conditional statement that checks the condition. If the condition is found to be true, the code inside the if braces will execute.
And if the condition is false, it skips the code inside the if braces and goes to the next one.
Below is the flowchart to understand the logic of the "if" statement clearly.
If Statement Flowchart :
First step: → You will write the program | Second step: → Now, you will check the condition (true/false) If you find "True", then. | Execute Code If you find the statement to be "False", then. | Do Nothing (Skip the code) | End the program
Syntax:
if (condition) {
// if the condition is true then code runs.
}
Example:
<?php
$temperature = 30;
if ($temperature > 25) {
echo "It is a hot day.";
}
?>
Output:
It is a hot day.
