Re: function by reference
| From: | Robert Cummings | Date: | Sun, 09 Apr 2006 23:01:02 +0000 |
| Subject: | Re: function by reference | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233640@lists.php.net to get a copy of this message | ||
On Sun, 2006-04-09 at 14:17, tedd wrote:
> Hi gang:
>
> Not that I have an immediate need for this, but in other languages
> one can access a function by reference (in other words, it's address
> -- such as call(function address) ).
>
> In php, one can pass a variable by reference by simply using the
> ampersand, such a &$a.
>
> Is there a similar way to reference a function?
>
> Rob, was kind enough to post the following code, but I was looking
> for something where I could store the function's address in a
> variable. Something like:
>
> $a = &f_a();
>
> And then, where I could use call_user_func($a); (or something
> similar) and the function would do it's thing -- anything like that?
It's the same thing for the most part...
<?php
$a = 'f_a';
call_user_func( $a, $p1, $p2, $p3 )
?>
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'