#24644 [Opn->Fbk]: Fata error because of private method

From: Date: Mon, 14 Jul 2003 19:26:42 +0000
Subject: #24644 [Opn->Fbk]: Fata error because of private method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-43976@lists.php.net to get a copy of this message
ID: 24644 Updated by: helly@php.net 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) New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#43976) next »