ID: 24644 Updated by: [EMAIL PROTECTED] Reported By: Bertrand dot Willm at laposte dot net -Status: Open +Status: Feedback Bug Type: XML related Operating System: Windows XP PHP Version: 5.0.0b1 (beta1)
Previous Comments: ------------------------------------------------------------------------ [2003-07-16 02:54:13] [EMAIL PROTECTED] Not good, but anyway please try without & for $this: array($this...) ------------------------------------------------------------------------ [2003-07-16 01:15:11] Bertrand dot Willm at laposte dot net I replace the following line : xml_set_element_handler($parser, 'StartElement', 'EndElement'); with : xml_set_element_handler($parser, array(&$this, 'StartElement'), array(&$this, 'EndElement')); but PHP crashes. ------------------------------------------------------------------------ [2003-07-14 14:26:41] [EMAIL PROTECTED] The only interesting part here is that the error message should say that private method StartElement() was called. The problem is that by the call to xml_parse() the connection to the instance gets lost. you should use array($this,'<method_name>') instead. Try that please. ------------------------------------------------------------------------ [2003-07-14 08:27:23] Bertrand dot Willm at laposte dot net Description: ------------ I make a class to parse XML. The element handler functions are private methods. I tried to call a private method from the StartElement handler. There is a fatal error. This should not be the case as all these functions are declared in the same class. In a class, private function should have access to the other private functions of the class. Reproduce code: --------------- class CBaseClass { var $name; function Parse() { $parser = xml_parser_create(); xml_set_object($parser, $this); xml_set_element_handler($parser, 'StartElement', 'EndElement'); xml_parse($parser, '<xml><node/></xml>', true); xml_parser_free($parser); } private function StartElement() { $this->PrivateFunction(); } private function EndElement() { } private function PrivateFunction() { } } class CExtClass extends CBaseClass { } $ExtObject = new CExtClass(); $ExtObject->Parse(); Expected result: ---------------- no error Actual result: -------------- Fatal error: Call to private method cbaseclass::PrivateFunction() from context 'cextclass' in c:\sitesweb\www\test.php5 on line 14 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24644&edit=1