We use PHP if statement to control the PHP program flow based upon conditions. It is used to route program execution. Here is the general form of if statement.
Under the if statement the condition part returns a boolean value. If the condition is true then the statement is executed.
It is a single statement but if the statement is complex we must enclosed the statement or block of code with curly braces otherwise the second statement is executed (if the condition is true or not). Here’s the form is
Now we try to solve a problem with PHP if statement. Here, if Rahim‘s age is greater than 20, then it print Rahim is old boy.
echo ” Rahim is old boy”;