How can I reset all PHP variables in the current scope?

I need this for debugging purposes and you need to reset all variables. Is there a way to get all the variables? and is there a way to keep track of all calls after the script completes? without changing my code. Please note: I cannot use xdebug or anything that can be installed because my script is running on the host.

+5
source share
2 answers

Check get_defined_vars in PHP.

This function returns a multidimensional array containing a list of all defined variables, be it the environment, server, or user variables, within the scope called by get_defined_vars ().

+9
source

You can try to use get_defined_vars.

<?php
    $a = 12;
    $b = "foo";
    $bar = "test";

    echo '<pre>';
    print_r(get_defined_vars());
?>

http://codepad.viper-7.com/UI38ud

+5
source

All Articles