NYCPHP Meetup

NYPHP.org

[nycphp-talk] OO PHP-Gtk

Scott Mattocks crisscott at netzero.com
Thu Apr 15 10:55:45 EDT 2004


>  function connect ($event, $callback) {
>    $callback[0]->{$callback[1]}();
>  }

Is this how php-gtk handles callbacks?  I was under the impression that 
it was done statically.  So that with your example it would look more like:

function connect ($event, $callback) {
   $callback[0]::{$callback[1]}();
}

I think it has to be calling the methods statically because if I have 
two methods, one that sets the member var and the other that checks the 
value and reacts, I get very confusing results.

...
var $memberVar = FALSE;
...
$button->connect('event', array($this, 'method1'));
$button->connect_after('event', array($this, 'method2'));
...
function method1() {
   echo $this->memberVar;
   $this->memberVar = TRUE;
   echo $this->memberVar;
}
funciton method2() {
   if ($this->memberVar) {
     echo 'It worked';
   } else {
     echo 'It didn't work';
}
...

Method one will print exactly what you would expect, but when I get to 
method2, memberVar is FALSE again and I get 'It didn't work.'

Thanks,
Scott Mattocks



More information about the talk mailing list