Re: Callback functions inside classes - how to?

From: Date: Sat, 09 Oct 2004 05:22:01 +0000
Subject: Re: Callback functions inside classes - how to?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-199049@lists.php.net to get a copy of this message
http://php.net/language.types.html#language.pseudo-types "Thomas Hochstetter" <fisherofmen@gmx.net> wrote in message news:php.general-199028@news.php.net... > Hi again, > > I have always been wondering how this is done properly: > > Here is an example: > > [snip] > class A { > function name( $a, $b, $c) { > $tmp = array(); > $tmp[a] = $a; > . > array_push( $GLOBALS['XMLStack'], $tmp ); > } > > function parse() { > .. some definitions . > $parser->set_handler( "root/page/title", "name" ); > . some more stuff here . > } > } > [/snip] > > What I want is to have the callback function name as it is in the above > example. But, obviously, the above code won't work. So, how do I tell the > set_handler function that it must use the name function from the class? > Using: > "A::name" or "$this->name" (if instantiated) . how do these callback > function calls work, because the same issue is with the xml handler > functions in php4 (have not as yet been to v5). > > Also, how can I get the data from the callback function out without using > $GLOBALS? I cannot just return an array, can I? > > Any ideas. > > Thanks so long. > > Thomas >

« previous php.general (#199049) next »