# php $HTTP_SERVER_VAR[]



## peterjcs (Jan 23, 2007)

I am really new to php. So i hope someone could help me to solve the difficulty that i face.

Could someone please help me to explain what is the use of $HTTP_SERVER_VAR[];. 


-----------------------
$page_location = $page_location ."?". $HTTP_SERVER_VAR["QUERY_STRING"];

What is the use of the question mark that is put in between $page_location and $HTTP_SERVER_VAR?

And what does the query_string mean?

-----------------------

---------------------------

And another question is what does the "\r" mean in php. why it is use in the email injection check.


=======================
By providing a simple example for the explanation is much appreciated
=======================


thank you:wave: :wave:


----------



## gamerman0203 (Oct 28, 2005)

$HTTP_SERVER_VAR is an older version of $_SERVER. They are predefined variables that serve many useful and powerful functions. To many to explain. Check out http://us2.php.net/reserved.variables for more.
-------
$page_location is a variable that was set in the script at another point. It's probably a string that contains the domain path used to get to the current page or something similiar. $HTTP_SERVER_VAR['QUERY_STRING'] is the same as $_SERVER['QUERY_STRING']. It retrieves everything after the "?" in the URL, if any. So what they are doing is setting the variable $page_location equal to what $page_location currently is plus adding the question mark and the query string to it.
-------
"\r" is a carriage return
http://us2.php.net/types.string

I hope this helps at all.


----------



## peterjcs (Jan 23, 2007)

thank gamerman0203.

However i am still not clear about "\r". I know it means carriage reture, but what does it mean? And how to use it?

Thank You


----------



## gamerman0203 (Oct 28, 2005)

A carriage return is essentially a "space".

example w/o carriage:
echo "the dog ran fast";
echo "but where did he run to?";
would output:
the dog ran fastbut where did he run to?

example w/ carriage:
echo "the dog ran fastr\";
echo "but where did he run to?";
would output:
the dog ran fast but where did he run to?

You can see all it did was add a space after "fast". It is essentially useless to HTML ouput other than to connect two strings with a space in the middle. And that's only if you are doing all through php. If you have HTML with embedded php output, than the HTML will put the space in for you. It's really not that important of a function.


----------

