I know this question seems hacky and weird, but is there a way to remove a function at runtime in PHP?
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.
I found out runkit_function_remove but runkit isn't enabled on my Web host. Is there another way to do that?
BTW I only support PHP 5.1.0.
Edit: I knew my question was hacky but here is the exact thing I want to do:
if (function_exists('get_magic_quotes_gpc') && @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');
}
Since "stripslashes_deep" will only live 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 there. I hope it's clearer now. Non-hacky solution suggestions are welcome too!