Forum Moderators: coopster

Message Too Old, No Replies

Need some help making my PHP code echo something else

         

DigitalSky

12:35 am on Jul 25, 2012 (gmt 0)

10+ Year Member



Okay, here is the code I've written below. What it does is it determines if you're on a specific page URL and depending on the URL you're on it will echo some particular HTML code which is exclusive to that page (or set of pages).

It works perfectly so far but one thing I wanted it to do (which I don't know how to do at the moment) is that I want it to echo some other HTML code if a particular page is not found in ago of those 'case' statements.

So for instance, if I have a bunch of URLs that aren't in the code below I want it to default to echoing something other HTML code. Make sense?

Anyhow, here is my code...


<?php

switch($_SERVER['REQUEST_URI']) {
case '/about-us/':
case '/faa-advisory/':
case '/policies/';
case '/contact-us/';
echo
'I plan on putting some HTML code here';

break;

case '/shop/category/bird-diverters/';
case '/shop/firefly-hw-bird-diverters/';
case '/shop/firefly-ff-bird-diverters/';
case '/shop/firefly-wm-bird-diverters/';
echo
'I plan on putting some different HTML code here';

break;

}

?>

incrediBILL

2:31 am on Jul 25, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Instead of case you use default such as:

switch($a) {
case '1': echo 'One'; break;
case '2': echo 'Two'; break;
default: echo 'everything else'; break;
}

DigitalSky

2:59 am on Jul 25, 2012 (gmt 0)

10+ Year Member



Worked like a charm! Thank you so much!