PHP Simple if Statement With Example

if Statement

This statement is used for testing a condition and excuting a part of code based on the result of the condition.
The condition shuld be a boolean expression which evaluates to either true or false.

if(expression or condition)
}
..................
Statement;
}

The condition or test expression is evaluated.

If the result of the expression is true a bloack of statements will be executed.

If the result is false the program continues from the next statement after the if block.

Syntax :




folowchart

Example:



Result:


good Morning!
have a good day!	


Read Also: