View Full Version : $_server
marain
04-02-2013, 01:21 PM
Partial output of
echo '<br />
<br />
<br />
$_SERVER
<br />
<br />
<br />';
foreach ($_SERVER as $bigkey => $bigvalue) {
echo "The value of $_SERVER $bigkey is $bigvalue <br />";
}
at http://www.njexpungements.com/test.php:
The value of Array REQUEST_URI is /test.php
The value of Array SCRIPT_NAME is /test.php
The value of Array PHP_SELF is /test.php
Presumably the three indicated elements are not interchangeable, but I can't see the difference.
Thoughts?
A.
Beverleyh
04-02-2013, 01:34 PM
http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm
marain
04-02-2013, 01:39 PM
Awesome!
A.
djr33
04-02-2013, 05:29 PM
Mod's note: the forum software automatically makes words lowercase in order to prevent "screaming" titles. In this case it's changing $_SERVER to $_server, which would not be functional. It probably won't matter for anyone, but just in case someone comes across this thread, you must use $_SERVER.
Here's the official documentation:
http://php.net/manual/en/reserved.variables.server.php
The value of Array REQUEST_URI is /test.php
The value of Array SCRIPT_NAME is /test.php
The value of Array PHP_SELF is /test.php
Presumably the three indicated elements are not interchangeable, but I can't see the difference.I can't remember the exact differences, but they can vary. They'll usually be the same, but if you are using mod_rewrite for 'pretty URLs' you'll get some variation here (the requested filename, and the actual file on the server), and I believe the other two might vary based on how you use include(), although I'm not certain about that.
For the record, you can test all of this another way:
print_r($_SERVER);
Note that $_SERVER can vary slightly on different servers (and depending on your configuration or maybe even how a page loads), so it's worth checking your configuration as well as the manual.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.