title: Unset all variables in PHP script
body: <p>Trying to unset automatically all variables in script.</p>
  
  <p>Have tried this way:</p>
  
  <pre><code>  echo '&lt;br /&gt; Variables in Script before unset(): &lt;br /&gt;';
    print_r(array_keys(get_defined_vars()));
    echo '&lt;br /&gt;&lt;br /&gt;';
    var_dump(get_defined_vars());
  
    // Creates string of comma-separated variables(*) for unset.
    $all_vars = implode(', $', array_keys(get_defined_vars()));
  
    echo '&lt;br /&gt;&lt;br /&gt;';
    echo '&lt;br /&gt;List Variables in Script: &lt;br /&gt;';
    echo $all_vars;
    unset($all_vars);
  
    echo '&lt;br /&gt;&lt;br /&gt;';
    echo '&lt;br /&gt;Variables in Script after unset(): &lt;br /&gt;';
    print_r(array_keys(get_defined_vars()));
    echo '&lt;br /&gt;';
    var_dump(get_defined_vars());
  </code></pre>
  
  <p>Why does it not work? </p>
  
  <p>Is there a better way to do this?</p>
  
  <p>Thanks for helping!</p>
  
  <p><code>(*) It's seems somewhat that it does not really create the variables, but a string that looks like variables...</code></p>