I have been trying to better understand how php works on a more in depth level, and recently I have been tinkering with arrays.
Using print_r() I have been studying the $GLOBAL array, and I found something I can't seem to find an explanation for.
In my $GLOBALS array there are variables I have set in a configuration file, but never actually made into globals.
Take the following code, and its output for example.
echo "<pre>";
echo print_r($GLOBALS);
echo "</pre>";
The output:
Array
(
[GLOBALS] => Array
*RECURSION*
[_POST] => Array
(
)
[_GET] => Array
(
)
[_COOKIE] => Array
(
[phpSESSID] => fai4rtfgdt6o6iaihh62d0pa15
)
[_FILES] => Array
(
)
[_SERVER] => Array
(
[HTTP_HOST] => DOMAIN
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5
[HTTP_ACCEPT_ENCODING] => gzip,deflate
[HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7
[HTTP_KEEP_ALIVE] => 115
[HTTP_CONNECTION] => keep-alive
[HTTP_REFERER] => http://DOMAIN/test.php
[HTTP_COOKIE] => PHPSESSID=fai4rtfgdt6o6iaihh62d0pa15
[HTTP_CACHE_CONTROL] => max-age=0
[CONTENT_TYPE] => application/x-www-form-urlencoded
[CONTENT_LENGTH] => 67
[PATH] => /sbin:/usr/sbin:/bin:/usr/bin
[sERVER_SIGNATURE] =>
[sERVER_SOFTWARE] => Apache
[sERVER_NAME] => DOMAIN
[sERVER_ADDR] => IPADDRESS
[sERVER_PORT] => 80
[REMOTE_ADDR] => 198.65.168.24
[DOCUMENT_ROOT] => /home/USER/www/DOMAIN
[sERVER_ADMIN] => webmaster@DOMAIN
[sCRIPT_FILENAME] => /home/USER/www/DOMAIN/test.php
[REMOTE_PORT] => 43272
[GATEWAY_INTERFACE] => CGI/1.1
[sERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => POST
[QUERY_STRING] =>
[REQUEST_URI] => /test.php
[sCRIPT_NAME] => /test.php
[php_SELF] => /test.php
[REQUEST_TIME] => 1286050077
)
[date] => October 2, 2010
[db_date] => 10/02/2010
[error] => Array
(
)
)
1
The 3 items at the bottom.
[date] => October 2, 2010
[db_date] => 10/02/2010
[error] => Array
Were set inside of a php config file. My question is, how did they end up in the $GLOBALS array?