Should we manually set $_SERVER['REQUEST_URI']
or will the server itself provide it?
Because I am not able to get it in my code,
$Gpath = explode('/login.php', $_SERVER['REQUEST_URI']);
Nope, we shouldn't. It's set by the server.
Your code makes not much sense though.
You'd better tell us what it's intended for, so we can tell you a proper way
No you should not manually set it. It is a predefined variable.
If you're planning to deploy on Linux/Unix system, this variable will in all likelyhood be correctly set, so you should simply use it as-is.
However, as you're developing on Windows XP, you may need to fake it with a script along the lines of:
// Fake REQUEST_URI on Windows.
if(!isset($_SERVER['REQUEST_URI']) && strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
if($_SERVER['QUERY_STRING']) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}
N.B.: I'm not running on Windows, so can't test this, but you should be able to cobble something together along these lines. (If you do a print_r($_SERVER)
, you can see what's available.)