Home‎ > ‎PHP‎ > ‎

Conditional

PHP have following conditional statements.
  • if
  • if. else
  • if. else if
  • switch
Example : if-else

$name = "SKJ" ;

if($name == "SKJ")
{
    echo "Right" ;
}
else
{
    echo "Wrong" ;
}

Example : Switch

switch($name)
{
    case 'SKJ' :
    {
        echo "OK" ;
        break ;
    }
    default :
    {
        echo "Default Execute." ;
        break ;
    }
}
Comments