Page 1 of 1

$_SERVER[]

Posted: Mon Dec 29, 2008 8:15 pm
by truepal20032001
Is there a $_SERVER[] function that returns a string of the directory... , not necessarily "PHP_SELF" but is there another one that will give you with the full URL like ------
"http://website.com/folder1/folder/
excluding the file itself....

Re: $_SERVER[]

Posted: Mon Dec 29, 2008 8:37 pm
by omniuni
Not so far as I know. I spent a while looking for this myself, and gave up. You'll have to either parse the string yourself, or figure some other solution.

If you find this, though, I would love to know. It would simplify things.

Re: $_SERVER[]

Posted: Mon Dec 29, 2008 8:46 pm
by requinix
In $_SERVER the formula is

Code: Select all

"http://" + SERVER_NAME + ":" + SERVER_PORT + dirname(SCRIPT_NAME)
The :port can be omitted if you're on port 80. If the server is on Windows then dirname will return give you a string with \s that need to be converted to /s.

Re: $_SERVER[]

Posted: Mon Dec 29, 2008 9:09 pm
by omniuni
would you mind elaborating on that just a bit?

Re: $_SERVER[]

Posted: Mon Dec 29, 2008 9:31 pm
by truepal20032001
tasairis wrote:In $_SERVER the formula is

Code: Select all

"http://" + SERVER_NAME + ":" + SERVER_PORT + dirname(SCRIPT_NAME)
The :port can be omitted if you're on port 80. If the server is on Windows then dirname will return give you a string with \s that need to be converted to /s.
thankyou!

Re: $_SERVER[]

Posted: Tue Dec 30, 2008 1:52 pm
by califdon
It's all there: http://us.php.net/reserved.variables.server

Just enter $_SERVER into Google.