The IF structure is one of the most important features of any programming languages which provide the conditionally transfer of control. The PHP IF structure is similar to the C language IF structure.
Syntax:
if (expr)
{
statement 1;
statement 1;
}
Where expression is any logical expression. If expression evaluates to TRUE then the statement in the body of IF structure will be executed other wise control transfer to next statement.
Note: if you have a single statement in the body of IF then there is no need of opening parentheses { and closing parenthesis }.
The following example compare the two value and give the large value.
$b) echo "a is larger than b"; ?>
If you have more then one statements in the body of the if statement then you must place all statement in the opening parenthesis and closing parenthesis.
$b) { echo "a is larger than b"; echo "done"; } ?>
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function