Skip to content
Advertisement

Displaying get_defined_vars() as an array which can contain html in values

As the title says, I want to make a “debug” site that displays the get_defined_vars() vars as an array.

It seems like some variables contain or can contain HTML or even dynamic code like PHP.

First I tried the classic:

<pre>
<?=print_r(get_defined_vars());?>
</pre>

then I played with htmlentities() and htmlspecialchars() commands and wrote this:

$allVars=get_defined_vars();
array_walk_recursive($allVars, function (&$value) {
    $value = htmlspecialchars($value, ENT_QUOTES);
});
print_r($allVars);

this takes forever and outputs a blank sheet 🙂

What would be the best way to do this?

Advertisement

Answer

maybe try this :

error_reporting(E_ALL)

E_ALL not ALL 😉

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement