Is there a way to give a "var_dump" in all variables instantiated in that context, without having to put each one inside var_dump ()?
Is there a way to give a "var_dump" in all variables instantiated in that context, without having to put each one inside var_dump ()?
get_defined_vars () : Get all variables defined in print_r
or var_dump
to view their respective values. The value of superglobals is also returned $_POST
, $_GET
, $_FILE
, $_SERVER
, $_COOKIE
, etc.
Global Scope:
<?php
$nome = 'joão';
$idade = 30;
$profissao = 'programador';
$itens = array(1,2,3,4,5,6);
$arr = get_defined_vars();
Local Scope:
<?php
function foo(){
$local = 'exibe apenas a variavel $local';
$arr = get_defined_vars();
echo '<pre>';
print_r($arr);
}
foo();
In addition to the get_defined_vars()
function, mentioned in the @ lost response, in certain situations there is another one that can be very useful.
The get_defined_constants()
function displays all constants defined and their values .