PHP Variables Getting all defined variables


get_defined_vars() returns an array with all the names and values of the variables defined in the scope in which the function is called. If you want to print data you can use standard functions for outputting human-readable data, like print_r or var_dump.


Note: This function usually returns only 4 superglobals: $_GET,$_POST,$_COOKIE,$_FILES. Other superglobals are returned only if they have been used somewhere in the code. This is because of the auto_globals_jit directive which is enabled by default. When it's enabled, the $_SERVER and $_ENV variables are created when they're first used (Just In Time) instead of when the script starts. If these variables are not used within a script, having this directive on will result in a performance gain.