I need to know if any php function shows me all the variables that are defined on the screen.
I'm doing an integration where I depend on other files that I do not have access to and I need to show all the variables I can access
Thanks in advance
I need to know if any php function shows me all the variables that are defined on the screen.
I'm doing an integration where I depend on other files that I do not have access to and I need to show all the variables I can access
Thanks in advance
How you indicate the get_defined_vars()
returns the different variables. Even so, I would like to give a little more information to respect by following the documentation .
In the example shown:
<?php
$b = array(1, 1, 2, 3, 5, 8);
$arr = get_defined_vars();
// print $b
print_r($arr["b"]);
/* print path to the PHP interpreter (if used as a CGI)
* e.g. /usr/local/bin/php */
echo $arr["_"];
// print the command-line parameters if any
print_r($arr["argv"]);
// print all the server vars
print_r($arr["_SERVER"]);
// print all the available keys for the arrays of variables
print_r(array_keys(get_defined_vars()));
?>
That is, according to the parameters you can obtain specific variables or obtain them and save them all (as in the latter case) and be able to work with them.
Searching in different sites, in the end I found a solution. I leave the code in case someone else needs it.
<?php
$vars = get_defined_vars();
print_r($vars);
?>
It will show on the screen all the variables, $ _POST, $ _GET, $ _SESSION, $ _COOKIES, $ _SERVER, and those that you have defined