> >> $foo = new Bar();
> >> $a = 'my_method';
> >> $result = $foo->{$a}();
> >>
> >> Very useful sometimes.
> >
> > Yes, but indirection can easily be overused. Please don't overuse as it
> > makes reading other's code that much harder.
> >
>
> Hah, just imagining a project from hell that would d
On Sun, Jan 11, 2009 at 1:34 PM, Hans Zaunere wrote:
>> $foo = new Bar();
>> $a = 'my_method';
>> $result = $foo->{$a}();
>>
>> Very useful sometimes.
>
> Yes, but indirection can easily be overused. Please don't overuse as it
> makes reading other's code that much harder.
>
Hah, just imagining
> > Sweet so, I think
> >
> > $a = 'my_func';
> >
> > does it for me.
>
> Also works with properties and methods of objects:
>
> $foo = new Bar();
> $a = 'my_method';
> $result = $foo->{$a}();
>
> Very useful sometimes.
Yes, but indirection can easily be overused. Please don't overuse as it
ma
On Sun, Jan 11, 2009 at 1:47 AM, Jesse Callaway wrote:
> Sweet so, I think
>
> $a = 'my_func';
>
> does it for me.
Also works with properties and methods of objects:
$foo = new Bar();
$a = 'my_method';
$result = $foo->{$a}();
Very useful sometimes.
__
Sweet so, I think
$a = 'my_func';
does it for me. I'd love to understand the following code, but I'll have to
read it a couple more times. Haven't quite gotten into classy stuff like
this yet. Looks like actionscript to me with this execute function.
Thanks so much. I didn't expect to get this g
umm... with objects this gets sexy.
class Add {
public function execute($a, $b) { return $a + $b; }
}
class Subtract {
public function execute($a, $b) { return $a - $b; }
}
$executors = array(array('object'=>new Add(), 'params' => array(1,1)));
foreach ($executors as $execute)
{
ec
Oh sorry, forgot to add this too, which I think better fits your question:
prints:
hello
On Sat, Jan 10, 2009 at 5:40 PM, Brian O'Connor wrote:
> I believe this is what you're looking for.
>
> I've done similar things in the past, but I don't have the code handy.
>
> http://www.php.net/manua
I believe this is what you're looking for.
I've done similar things in the past, but I don't have the code handy.
http://www.php.net/manual/en/language.variables.variable.php
On Sat, Jan 10, 2009 at 2:45 PM, Jesse Callaway wrote:
> Is it possible to take a reference to a function and then stic
Is it possible to take a reference to a function and then stick it in an
array?
I'd like to have an array with function names as the keys and the values
would be references to the actual function. This way I could do
do[$that_function];
Basically being lazy and don't want to have a big ugly swi