[ Team LiB ] Previous Section Next Section

Q&A

Q1:

HTTP seems a little esoteric. Do I really need to know about it to write good PHP code?

A1:

No. You can write excellent code with knowing the intricacies of client/server interaction. On the other hand, a basic understanding of the process is useful if you want to do more than just download pages from remote servers.

Q2:

If I can send fake headers to a remote server, how suspicious should I be of environment variables myself?

A2:

You should not trust environment variables such as $_SERVER['HTTP_REFERER'] and $_SERVER['HTTP_USER_AGENT'] if their accuracy is essential to the operation of your script. Remember, though, that the vast majority of clients you deal with will tell you the truth. If you are merely ensuring a productive user experience by detecting browser type or gathering overall statistical information, there is no need to distrust this data.


    [ Team LiB ] Previous Section Next Section