title: Removing a function at runtime in PHP (without the runkit extension)
body: <p>I know this question seems hacky and weird, but is there a way to remove a function at runtime in PHP?</p>
  
  <p>I have a recursive function declared in a "if" block and want that function to be "valid" only in that "if" block. I don't want this function to be callled outside this block.</p>
  
  <p>I found out <a href="http://ca2.php.net/manual/en/function.runkit-function-remove.php" rel="noreferrer">runkit_function_remove</a> but <a href="http://ca2.php.net/manual/en/book.runkit.php" rel="noreferrer">runkit</a> isn't enabled on my Web host. Is there another way to do that?</p>
  
  <p>BTW I only support PHP 5.1.0.</p>
  
  <p><strong>Edit:</strong> I knew my question was hacky but here is the exact thing I want to do:</p>
  
  <pre><code>if (function_exists('get_magic_quotes_gpc') &amp;&amp; @get_magic_quotes_gpc())
  {
      function stripslashes_deep($value)
      {
          return is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
      }
  
      $_POST = array_map('stripslashes_deep', $_POST);
      $_GET = array_map('stripslashes_deep', $_GET);
      $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
      $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
  
      //runkit_function_remove('stripslashes_deep');
  }
  </code></pre>
  
  <p>Since "stripslashes_deep" will only <em>live</em> when Magic Quotes are ON, I wanted to get rid of it when I'm done with it. I don't want people to rely on a function that isn't always <em>there</em>. I hope it's clearer now. Non-hacky solution suggestions are welcome too!</p>