RandomBase.com logo
Announcement:
World of Warcraft Bots, need some help in choosing the best bot?

News Archives

Statistics

  • There are 12 users online.
  • Most users ever online was 424 on 03/16/08.
  • Our poor server had to serve 24 pages in the last 15 minutes.
  • And yet he managed to generate this page in 0.003 seconds.

Affiliates & friends

RandomBase.com isn't just one website - it is more.
RandomBase.com -> Tutorials -> [PHP] if/elseif/else PHP - if/elseif/else

One of the basics in most languages is the if-elseif-else structure. If you can't handle this I advise you to stop immedialty with programming/scripting !

The if-elseif-else structure is -normally- very easy !

Example :

    <?php
    
/*
    http://www.randombase.com
    */
    
    
$apples 5;            //There are 5 apples
    
    
If ($apples 5
    {
        echo 
'There are less then 5 apples';
    } 
    elseif (
$apples == 5)
    {
        echo 
'There are exactly 5 apples';
    } 
    else
    {
        echo 
'There are more then 5 apples';
    }
    
?>

When we dissect this script in normal language it will look like :

When There are less then 5 apples the page will say : 'There are less then 5 apples' but if the total of apples is equal to 5 then the page will tell us 'There are exactly 5 apples' and when neither of these 2 is correct There is only 1 possibility and that is that There are more then 5 apples !