In IF structure if the condition is true then statements in the body of IF will be executed and if condition is false then nothing will be executed and control transfer to next statement. But if you want to execute some statement in case of False result then you will use the IF and ELSE structure. In this structure if condition is true then statements in body of IF will be executed other wise the statements in body of ELSE structure will be executed. This also done by using two separate IF Statement.
Syntax:
if (expersion)
{
statement 1;
statement 1;
statement 1;
}
else
{
statement 1;
statement 1;
statement 1;
}
For example if we check the user name and use is tauqeer then its welcome otherwise user ask to login first. Now first we use Two separate IF statement to do this:
Now do this with single IF and ELSE structure.
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