Jump to content

Reliability of some $_SERVER elements.


JasonLewis

Recommended Posts

I'm curious as to how reliable some of the $_SERVER elements are, mainly the ones related to the URI and Query String.

 

What I'm doing is building a query string using $_SERVER['QUERY_STRING'], however I'm unsure of how reliable it is

 

I am aware that a few of the elements in the predefined variable can be unreliable, but what about the QUERY_STRING element?

 

Cheers.

Link to comment
Share on other sites

What you see is what you get on this var. Every http server needs a request uri. Therefor it will be populated in every condition except one:

When a PHP script is run from a command line or similar. Although I'm pretty sure this variable still populates even under those circumstances.

 

-cb-

Link to comment
Share on other sites

The $_SERVER vars are populated by the webserver, not PHP, so they are implementation dependent.  Take a look at the cgi spec.  I would assume that all of these will be implemented by modern webservers:  http://web.archive.org/web/20071018185254/http://hoohoo.ncsa.uiuc.edu/cgi/env.html

 

Well, according to that page in regards to QUERY_STRING:

 

This variable should always be set when there is query information, regardless of command line decoding.

 

Very good. Thanks for that link.

 

Thanks for your time guys. Appreciate it. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.