Is $_SERVER variable an array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Is $_SERVER variable an array?

16th Apr 2016, 7:55 AM
Ajay Verma
Ajay Verma - avatar
2 Answers
+ 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;
4th May 2016, 3:00 PM
Joseph Bonifacio
Joseph Bonifacio - avatar
+ 3
Yes .associative array
11th Jul 2016, 2:52 PM
SOLEYMAN
SOLEYMAN - avatar