tcorbeil Posted March 21, 2007 Share Posted March 21, 2007 Me again... is there a way to get just the url? for instance if I have an address such as Domain Name/Oilers/oilers.html in every instance I do $path = $_SERVER['SCRIPT_NAME']; I get /Oilers/oilers.html If i just want /Oilers/ with the file running name at the end, how would I go about? Thanks. T. Link to comment https://forums.phpfreaks.com/topic/43699-_server-help/ Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 You can use split or try $_SERVER['DOCUMENT_ROOT']; If you setup a phpinfo(); somewhere you can view what the server variables have in store and see which to use. Or do print_r($_SERVER); Link to comment https://forums.phpfreaks.com/topic/43699-_server-help/#findComment-212145 Share on other sites More sharing options...
tcorbeil Posted March 21, 2007 Author Share Posted March 21, 2007 Thanks Frost. I tried print_r($_SERVER); and seen all of the info.. none of the switch variable would give the path without the file running at the end.. can you elaborated on the split idea? Could I also not use a rtrim up until the first '/' it encounters? Thanks. T Link to comment https://forums.phpfreaks.com/topic/43699-_server-help/#findComment-212153 Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 <?php list(,$dir) = split("/", $_SERVER['SCRIPT_NAME']); print $dir; // should print "Oilers" ?> Link to comment https://forums.phpfreaks.com/topic/43699-_server-help/#findComment-212157 Share on other sites More sharing options...
tcorbeil Posted March 21, 2007 Author Share Posted March 21, 2007 Frost your a genius! Thanks Man! T. Link to comment https://forums.phpfreaks.com/topic/43699-_server-help/#findComment-212166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.