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 Quote 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') { } Quote 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"){ } ?> Quote 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.. Quote 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 Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.