Warptweet Posted January 21, 2007 Share Posted January 21, 2007 What code would I use to check if I'm on a page like...ifhttp://www.warptweet.com/index.phpthendisplay this code blah blah blahifhttp://www.warptweet.com/flashportal.phpthendispaly this code blah blah blahifhttp://www.warptweet.com/uploadthendisplay this code balh blah blahSo basically, check what page it's viewing? Link to comment https://forums.phpfreaks.com/topic/35067-check-if-on-page/ Share on other sites More sharing options...
webren Posted January 21, 2007 Share Posted January 21, 2007 An idea would be to store the value between your <title> and </title> tags into a variable and compare. So you could have...[code]if ($title == "Index") echo "You are at the main page.";else if ($title == "Page 1") echo "You are at Page 1.";[/code]...and so forth. Link to comment https://forums.phpfreaks.com/topic/35067-check-if-on-page/#findComment-165494 Share on other sites More sharing options...
Warptweet Posted January 21, 2007 Author Share Posted January 21, 2007 Anyone else have any ideas or methods?As I understand this is a nice idea, there are still some possible flaws that may occur when I use this. Link to comment https://forums.phpfreaks.com/topic/35067-check-if-on-page/#findComment-165504 Share on other sites More sharing options...
448191 Posted January 21, 2007 Share Posted January 21, 2007 Why don't you just test against $_SERVER['REQUEST_URI']? ;) Link to comment https://forums.phpfreaks.com/topic/35067-check-if-on-page/#findComment-165642 Share on other sites More sharing options...
tippy_102 Posted January 21, 2007 Share Posted January 21, 2007 I use this for my counter - only want to count the index page, but counter is in the footer file so is included on all pages.[code]$realname = basename($_SERVER[SCRIPT_FILENAME], ".php");if ($realname == 'index'){ do stuff}[/code] Link to comment https://forums.phpfreaks.com/topic/35067-check-if-on-page/#findComment-165772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.