Transfer of Control In PHP

Nested IF Structure in PHP

Nested IF Structure means when one IF statement is placed in The body of other IF statement then it is called Nested IF Structure. In PHP IF and ELSEIF statement is used for this purpose.
Syntax:


<?php
if (condition)
<br>
     {
            statments ;
    }

        elseif (different condition)

         {
            Statments ;
           }

           else

            {
            statments

            }
?>

Lets take an example to understand this structure. Take a number and decided that Numbre is +ve or -ve or zero.


<?php

$number=2;
    if ($number>0) 
    { 
    echo "Number is +ve" ; 
    } 
        elseif ($number < 0) 
        { 
        echo " Number is -ve "; 
        } 
    else 
    { 
    echo "Number is Zero"; 
} 
?>