Where is my object? (scope rules, xml, and much fun)

From: Date: Thu, 28 Sep 2000 17:26:52 +0000
Subject: Where is my object? (scope rules, xml, and much fun)
Groups: php.general 
Request: Send a blank email to php-general+get-17932@lists.php.net to get a copy of this message
Hi, the four attached files will run fine if you call them as they stand now. If you uncomment the $this->Template->printer(); in the printItem function of the eZNewsCustomerHH object, you'll get a "<b>Fatal error</b>: Call to a member function on a non-object in <b>eznews/classes/eznewscustomerhh.php</b> on line <b>157</b><br>". What is going on? For those of you who don't see how this slew of code is supposed to work, here's a quick walk through. Read this http://www.phpbuilder.com/columns/joe20000907.php3" on XML, then ask your self, how can I do this dynamically and through objects... Well, take file eznewsxmlparser.php, that file is the parser code, exactly as Joe Stump describes it in his article. Each time you need some parsing done, call that file. We need a global $data element floating around for this to work. Eznewsxmlparser.php includes eznewsxmlfunctions.php. This file has the callback functions which we registered with the xml_parser object in the first file. You can see that this one assumes that we have yet another global, theXMLParser, which is an object which implements the interface of eZNewsXML. The functions in eznewsxmlfunctions.php has to be visible for the xml_parser, since I've found no way of tricking functions in objects into the xml_parser. Finally we have the eznewscustomerhh.php file. Inside that file there is a couple of global tag definitions, which is used as pr. Joes tutorial. Then there is a little phony class, which is used to illustrate my problem. Finally we come to the eZNewsCustomerHH class, which is the class I wan't to use. Most of Joe's article has by this point be abstracted away, and everything looks fine. That's until we get to any function in the eZNewsCustomerHH object after we've included the eznewsxmlparser.php file. After the xml parsing has been done, the object we're working on seems to have lost all knowledge of the previously created drop object. Where did it go? How is the scope, what on earth is happening. I'm this close from making an elegant system for parsing XML, but this screws it up. -- Paul K Egell-Johnsen The truth is out there - encrypted

Attachment: [text/x-java] eznewsxmlparser.php
Attachment: [text/english] eznewsxmlfunctions.php
Attachment: [text/english] eznewsxml.php
Attachment: [text/english] eznewscustomerhh.php
« previous php.general (#17932) next »