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>"; } ?> Link to comment https://forums.phpfreaks.com/topic/169234-solved-url-identify/ 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? Link to comment https://forums.phpfreaks.com/topic/169234-solved-url-identify/#findComment-892994 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. Link to comment https://forums.phpfreaks.com/topic/169234-solved-url-identify/#findComment-893002 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. Link to comment https://forums.phpfreaks.com/topic/169234-solved-url-identify/#findComment-893589 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! Link to comment https://forums.phpfreaks.com/topic/169234-solved-url-identify/#findComment-893595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.