monkeytooth Posted February 24, 2010 Share Posted February 24, 2010 What I want to do is get the equivalent of SERVER_NAME but along side it the trailing directory without the file its scripted in, So PHP_SELF minus the script.php..... Is using the _SERVER function appropriate for this or is there another function for it, or do I have to device something for it? Link to comment https://forums.phpfreaks.com/topic/193161-would-_server-be-used-for-this/ Share on other sites More sharing options...
trq Posted February 24, 2010 Share Posted February 24, 2010 $_SERVER is an array, not a function & yes, it will likely contain the information your looking for. Link to comment https://forums.phpfreaks.com/topic/193161-would-_server-be-used-for-this/#findComment-1017160 Share on other sites More sharing options...
monkeytooth Posted February 24, 2010 Author Share Posted February 24, 2010 Well I tried this to better figure the output of the _SERVER array, but I dont see anything output that would help me with what I want to find and use. All i can get remotely close out of it is the ones I mentioned in my original post. I know I could probably trim off the end, but its never a set amount of characters to trim off so that would likely back fire on me. All I want to do is find the bit after .com before script.php ex: http://www.mydomain.com/dir/index.php or http://www.mydomain.com/dir/dir/dir/index.php only the bold portion is what I seek if nothing is there and its just / or nothing at all I have to figure that out as well. But I dont know if theres a php function or array prebuilt into PHP that I can use to save time and size or if I have to come up with a function of my own in some sort way shape or another in order to do what I want. <?php echo '<table border="1">'; foreach($_SERVER as $k => $v) { echo '<tr><td>'.$k.'</td><td>'.$v.'</td></tr>'; } echo '</table>'; ?> Link to comment https://forums.phpfreaks.com/topic/193161-would-_server-be-used-for-this/#findComment-1017190 Share on other sites More sharing options...
trq Posted February 24, 2010 Share Posted February 24, 2010 echo dirname($_SERVER['REQUEST_URI']); Link to comment https://forums.phpfreaks.com/topic/193161-would-_server-be-used-for-this/#findComment-1017202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.