previously I was using the following script in PHP 5.5.9 to unset all variables, which was working very well

$vars = array_keys(get_defined_vars());
for ($i = 0; $i < sizeOf($vars); $i++) {
    unset($$vars[$i]);  //this is line 72

but now when i used same code in PHP 7 , this is giving  following messages:

PHP Notice:  Array to string conversion in /root/script.php on line 72
PHP Notice:  Undefined variable: Array in /root/script.php on line 72

after reading php 7 documentations and some research on internet i found that i have to use foreach instead of for 

$vars = array_keys(get_defined_vars());
foreach ($vars as $var) {
unset($vars, $var);

The order of evaluation of $$vars[$i] is different in PHP 7. It’s now strictly left to right.

Previously it would have first evaluated $vars[$i] and then formed a new variable from the result of that with $.

Now it first evaluates $$vars and then tries to find [$i] in the result of that.