Monk3h Posted August 7, 2009 Share Posted August 7, 2009 The following script is suposed to change the text to a link if it is not displayed on my home page. My problem is that it does not work, i think this is because my home page is in a directory higher than www. the full path to my home page is portfolio/4/index.php How would i change my script to check there without using the full path? <?php $homepage = "/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepage==$currentpage) { Print "<span style=color:#f0f492>Home</span>"; }else{ Print "<span style=color:#999999><a href='index.php'>Home</a></span>"; } ?> Quote Link to comment Share on other sites More sharing options...
Monk3h Posted August 7, 2009 Author Share Posted August 7, 2009 Also, when using the full path it does not work with index.php at the end or just / however if i use the script to identify any other page apart from index.php eg projects.php it works! any ideas? Quote Link to comment Share on other sites More sharing options...
alexdemers Posted August 7, 2009 Share Posted August 7, 2009 Do the logic. Check to see what $_SERVER['REQUEST_URI'] returns for each page. Just echo the variable. <?php $file_parts = explode('/', $_SERVER['REQUEST_URI']); $current_file = end($file_parts); ?> This will return the file only, not its directories. Quote Link to comment Share on other sites More sharing options...
Monk3h Posted August 8, 2009 Author Share Posted August 8, 2009 It reads back index.php Thats my problem! When i use index.php it dosnt work. Quote Link to comment Share on other sites More sharing options...
Monk3h Posted August 8, 2009 Author Share Posted August 8, 2009 PROBLEM SOLVED! Thanks for all the help! Quote Link to comment 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.