Posted by ZeldorBlat on 08/16/07 15:04
On Aug 16, 11:00 am, D_a_n_i_e_l <danwgr...@gmail.com> wrote:
> Is there some way to implement something like a virtual function or
> have something like a user defined function ? One solution I thought
> might work: store a reference (address) of a function in a variable
> and call it later if that variable has been set ? This seems to
> compile OK, but produces funny results. Is this outside the scope of
> php ?
>
> function testfn()
> {
> ...
> return $result;
>
> }
>
> $myfn = &testfn; // set it too the address of the function
> ...
> if (isset($myfn))
> $result = @$myfn(); // call my function
You can find out if a function exists using function_exists():
if(function_exists('testfn')
...
You can also call a function who's name is stored in a variable:
$myfn = 'testfn';
$result = $myfn(); //calls testfn()
Is that what you're trying to do?
Navigation:
[Reply to this message]
|