Jump to content

Would _SERVER be used for this?


monkeytooth

Recommended Posts

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

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>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.