[thelist] php SWITCH vs ELSE IF

Mark Mckee lists at soddengecko.com
Mon Apr 24 07:18:46 CDT 2006


hi all

I have written a short code to display a certain menu depending on which 
page it is on. the code works fine and I do get my desired results.

i am using an ELSE IF statement and would like to know if this would be 
better than using a switch statement.

sorry if this is a simple question but i was unable to find the answer 
with google and php websites.

thanks in advance.

the code:

<?php
if (is_page('miscellaneous'))
{
      echo $misc ;
}
elseif (is_page('associates'))
{
    echo $misc ;
}
elseif (is_page('downloads'))
{
    echo $misc ;
}
elseif (is_page('gallery'))
{
    echo $misc ;
}
elseif (is_page('reviews'))
{
    echo $misc ;
}
elseif (is_page('xbox'))
{
    echo $misc ;
}
elseif (is_page('moto-gp3'))
{
    echo $misc ;
}
?>

-- 


Mark...
http://www.soddengecko.com



More information about the thelist mailing list