Let's say I've subclassed Pear's XML_Parse as follows:
class MyXMLParser extends XML_Parser {
var $temp;
function startHandler ($xp, $elem, $attribs) {
$this->temp++;
}
function endHandler ($xp, $elem) {
$this->temp++;
}
}
$myp = new MyXMLParser();
$myp->setInputFile("some_xml_file.xml");
$myp->parse();
Doing a print on $this->temp while inside either startHandler or endHandler shows proper incrementation each time those functions are called. However, doing a print on $myp->temp once the $myp_parse() call is completed gives "null".
My question is, what is the scope that expat uses when it calls the event handler functions? It looks like it creates some local copy of the object which then goes out of scope when the xml_parse call finishes. How can I get around this without using global variables?
RyanDev