-2

I'm using PHP 7.2.3 on my machine that runs on Windows 10.

I've installed PHP using latest version of XAMPP.

I come across following text from PHP Manual :

$_SERVER is just one variable that PHP automatically makes available to you. A list can be seen in the Reserved Variables section of the manual or you can get a complete list of them by looking at the output of the phpinfo() function.

In the above text from PHP manual it has been clearly said that I can see the complete list of such variables which PHP automatically makes available to my script.

When I observed the output of phpinfo(); I could only see the entire array of $_SERVER[] superglobal variable. I couldn't see any other such predefined superglobal variables in the output of phpinfo();

Can I say this is a mistake in PHP manual?

Or can I say the manual is saying the thing rightly but I'm not able to get it and see the other predefined superglobal variables?

Please someone help me out in this regard.

Thank You.

Community
  • 1
  • 1
PHPLover
  • 1
  • 51
  • 158
  • 311

1 Answers1

0

There is a function called get_defined_vars() which does exactly what you want.

There are even more of them:

  1. get_defined_constants - Gets all constants
  2. get_defined_functions - Gets all functions
  3. get_defined_vars - Gets all variables
  4. get_declared_classes - Gets all declared classes

 I couldn't see any other such predefined superglobal variables in the output 

Screw what i said about this earlier. You are right, doc says

phpinfo() is also a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data.

It should be noted, that you find GET, POST and COOKIE in $_REQUEST and not in their array respectivly.


If you only want to get the super globals from phpinfo, try following:

phpinfo(INFO_VARIABLES);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Manuel Mannhardt
  • 2,191
  • 1
  • 17
  • 23
  • I got all your points except one : $_COOKIE (which makes sence not to display on phpinfo for security reasons). What are those security reasons? Please explain to me. – PHPLover Mar 19 '18 at 13:00
  • I´ve edited my answer. I was wrong it DOES contain these variables in info. It also contains the cookies in there. I messed up things in my head. Sorry for confusion :) – Manuel Mannhardt Mar 19 '18 at 13:02