Re: unsetting function
| From: | Miguel Cruz | Date: | Wed, 29 May 2002 20:33:15 +0000 |
| Subject: | Re: unsetting function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99798@lists.php.net to get a copy of this message | ||
On Wed, 29 May 2002, Laurent Drouet wrote:
> I would like to know if there is a way to unset a function or to replace
> function contents by an other ?
Not natively, that I know of.
If you think you'll have to do a lot of that, it's probably easier to keep
the function name in a variable, and just change that when you want the
function called to change.
<?
function add($a, $b) { return $a + $b; }
function subtract($a, $b) { return $a - $b; }
$mathfunc = 'add';
print '<br>' . $mathfunc(5, 3);
// now we want to replace mathfunc so it subtracts instead of adds:
$mathfunc = 'subtract';
print '<br>' . $mathfunc(5, 3);
?>
miguel