+ 4
Is $_SERVER variable an array?
2 odpowiedzi
+ 8
If you look at the code for the various elements, $_SERVER[element], you'll see that it returns different responses.
Note that when you have an array, when you want to pull a value you write it as follows array[0], for the first item.
It looks like $_SERVER is an associative array. So let's say you had an array with a name and age.
$Person = array(
"name" => "Joe",
"age" => 35
);
To set the age of person, you can do:
$personAge = $Person["age"];
So similarly:
$_SERVER = array(
"PHP_SELF" => "someFile.php",
"SERVER_ADDR" => "10.0.0.1",
....
);
And then to get the page you are running currently,
$pageNow = $_SERVER["PHP_SELF"];
echo $pageNow;
+ 3
Yes .associative array