I have a space in a global field that I want to be different on the homepage, so my thoughts were to create an if/else statement. if page = http://www.homepage echo = 'Statement 1' else echo = 'statement 2' That's an idea of what i'm looking for, but i'm a php novice. Could someone help me with this coding? Thanks!
You can use something like this: switch($_SERVER['PHP_SELF']): case '/index.php': echo 'SOMETHING ON THE INDEX PAGE'; break; default: echo 'ANY OTHER PAGE'; endswitch; PHP: This may not work as expected if you're using wordpress or another application where every page request is funnelled through the index.php page.
I should have mentioned i'm using a cms, and I have many mods with url rewrites, etc. which is why i was hoping I could just use the simple url.
Ok, when I use this code: <?php echo $_SERVER['REQUEST_URI']; ?> Code (markup): I get the output of "/" on my homepage. Can I still use that in a statement, or does it have to be a full directory name, etc? And i'm still unsure of how to exactly code this. I can echo $_SERVER['REQUEST_URI']; , but how do I use it in an if/else statement? It's getting to be near the end of the day, and I may just have to study some php tomorrow.
Glad you got it to work. Just to clarify, most of the time $_SERVER['REQUEST_URI'] retrieves everything past the URL itself. However, some browsers or applications may send the full URI including the URL, so you should watch out for that.
Thanks for that clarification. I better test this in a few browsers. What about search engines/spiders? That's what I'm doing this for the most, although it will benefit the viewer as well.