From what I’ve read, it seems that $_SERVER['REQUEST_URI'] won’t always return query strings properly, but does anyone have a good sense of what the success rate is? Will it work in the majority of cases for the average client?
What, if anything, would cause REQUEST_URI to not be populated or not include the query string?
You asked:
Answers that I can think of:
The web server provides all the
$_SERVERvalues to PHP, so if the server doesn’t provide them, then they won’t be set. This is highly unlikely with any decent web server, but is possible.If you run a PHP program from the command line, it won’t have any
$_SERVERvalues. (in case you’re not worried about this, bear in mind that unit tests are typically run from a command line, so it does matter if you’re following best practices and writing unit tests)