[nycphp-talk] Callback syntax
Brian D.
brian at realm3.com
Thu Dec 13 14:29:25 EST 2007
> call_user_func() treats everything as a static method and will not work.
While the variable function might work, could you clarify what you
mean by 'treats everything as a static method'?
I just ran this:<?php
class Foobar {
private $schmoo = 9;
function setSchmoo( $var ) {
$this->schmoo = $var;
}
function getSchmoo( ) {
return $this->schmoo;
}
function setCallbackSchmoo( $var ) {
call_user_func( array( $this, 'setSchmoo' ), $var );
}
}
$foo= new Foobar;
var_dump( $foo->getSchmoo( ) );
$foo->setCallbackSchmoo( 20 );
var_dump( $foo->getSchmoo( ) );
?>
And got this:
int(9)
int(20)
Which is precisely what I'd expect.
--
realm3 web applications [realm3.com]
freelance consulting, application development
(423) 506-0349
More information about the talk
mailing list