Re: Closures in PHP
| From: | Larry Garfield | Date: | Wed, 16 Jan 2008 06:58:40 +0000 |
| Subject: | Re: Closures in PHP | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267370@lists.php.net to get a copy of this message | ||
On Tuesday 15 January 2008, Nathan Nobbe wrote:
> when i said a function would have to be loaded into the interpreter to
> avoid a runtime error
> upon invocation, i didnt mention that its best to programatically verify it
> can be called before
> letting the runtime error occur (of course you can let that happen if you
> prefer :)), to avoid it.
> anywho, i prefer the variable function construct more than
> call_user_func(), simply
> because it feels a bit more natural to me, but semantically, they are the
> same, they just have
> a different syntax is all. i suppose call_user_func() is a bit more clear
> and might help some
> people when drifting through the code of others.
> cool contrived example, btw ;)
>
> -nathan
Not true, actually. $function() is considerably faster than call_user_func()
or call_user_func_array(). call_user_func_array(), however, lets you pass in
an arbitrary number of parameters while the other two do not.
--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson