matty Posted June 20, 2007 Share Posted June 20, 2007 How can I make an IF run only if the page is correct... For example : I want an IF like this IF(This Page == about.php){ Do this } So if I was on the about.php page it would do the IF, but if I was on the home.php page it wouldn't.. Thanks, Matt Link to comment https://forums.phpfreaks.com/topic/56416-solved-determine-ifs-on-page/ Share on other sites More sharing options...
Jaguar Posted June 20, 2007 Share Posted June 20, 2007 Use server variables if($_SERVER['PHP_SELF'] === 'about.php') { } Link to comment https://forums.phpfreaks.com/topic/56416-solved-determine-ifs-on-page/#findComment-278622 Share on other sites More sharing options...
techietim Posted June 20, 2007 Share Posted June 20, 2007 <?php $a = explode("/", $_SERVER['SCRIPT_NAME']); if(end($a) == "about.php"){ } ?> Link to comment https://forums.phpfreaks.com/topic/56416-solved-determine-ifs-on-page/#findComment-278623 Share on other sites More sharing options...
chigley Posted June 20, 2007 Share Posted June 20, 2007 if($_SERVER["PHP_SELF"] == "/about.php") { // ... } Untested.. Link to comment https://forums.phpfreaks.com/topic/56416-solved-determine-ifs-on-page/#findComment-278625 Share on other sites More sharing options...
matty Posted June 20, 2007 Author Share Posted June 20, 2007 Thanks for the replies guys. Il test them in a second Link to comment https://forums.phpfreaks.com/topic/56416-solved-determine-ifs-on-page/#findComment-278647 Share on other sites More sharing options...
matty Posted June 20, 2007 Author Share Posted June 20, 2007 Worked great! Cheers! Link to comment https://forums.phpfreaks.com/topic/56416-solved-determine-ifs-on-page/#findComment-278650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.