|
Posted by B.r.K.o.N.j.A on 08/17/06 15:21
Mathieu Maes wrote:
> Hi there
>
> I'm quite experienced in programming in PHP4, but I would like to make
> a step to PHP5.
> I created following class which works perfectly in PHP4 :
>
> [code]
> Class Nessi
> {
> // ident part
> var $user = ""; //the username
> var $password = ""; //the password
>
> // invoice records
> var $invoices = array(); //list of invoice records
> var $i = -1; //invoice counter
>
> // client records
> var $clients = array(); //list of client records
> var $j = -1; //client counter
>
> var $XML = ""; // The XML file content
> function OpenFile($filename)
> {
> // leest de inhoud van een bestand naar een string
> $handle = fopen ($filename, "r");
> $contents = fread ($handle, filesize ($filename));
> fclose ($handle);
> $this->XML = $contents;
> $this->ParseXML();
> }
>
> function ParseXML()
> {
> $doc = xmldoc($this->XML);
> $root = $doc->root();
> $children = $root->children();
>
> foreach($children as $child)
> {
> if ($child->type == "1")
> {
> switch ($child->tagname)
> {
> case "ident":
> $this->Ident($child);
> break;
> case "invoice":
> $this->Invoice($child);
> break;
> case "client":
> $this->Client($child);
> break;
> default: ;
> } // switch
> }
> }
> unset($this->XML);
> }
>
> function Ident($child)
> {
> $record = $child->children();
>
> foreach($record as $item)
> {
> if ($item->type == "1")
> {
> if ($item->tagname == "user")
> {
> $content = $item->children();
> $this->user = $content[0]->content;
> }
> if ($item->tagname == "pass")
> {
> $content = $item->children();
> $this->password = $content[0]->content;
> }
> }
> }
> }
>
> function Invoice($child)
> {
> $i = 0;
> $this->invoices[++$this->i] = array();
> $invoice = $child->children();
> foreach($invoice as $invitem)
> {
> switch ($invitem->tagname)
> {
> case "header":
> $header = $invitem->children();
> foreach($header as $headitem)
> {
> switch ($headitem->tagname)
> {
> case "clientid" :
> $text = $headitem->children();
> $this->invoices[$this->i]['clientid'] =
> $text[0]->content;
> break;
> case "clientinfo":
> $text = $headitem->children();
> $this->invoices[$this->i]['clientinfo']
> = $text[0]->content;
> break;
> case "date":
> $text = $headitem->children();
> $this->invoices[$this->i]['date'] =
> $text[0]->content;
> break;
> default: ;
> } // switch
> }
>
> break;
> case "items":
> $items = $invitem->children();
> foreach($items as $item)
> {
> if ($item->type == "1")
> {
> if ($item->tagname == "item")
> {
> $content = $item->children();
> $newitem['desc'] =
> $content[0]->content;
> $newitem['price'] =
> $item->get_attribute("price");
>
> $this->invoices[$this->i]['items'][$i++] = $newitem;
> unset($newitem);
> }
> }
> }
> break;
> default: ;
> } // switch
> }
> }
> function Client($child)
> {
> // not yet implemented...
> }
> }
> [/code]
>
> If I include this class into a script running in PHP5, I only get a
> blank output. In fact, the execution seems to stop when including or
> instantiating this class. I don't get any error message, even with
> error_reporting(E_ALL).
>
> What am I missing ?
>
I didn't really looked into your code but usually the biggest difference
between objects in php4 and php5 is that all the object variables are
passed by reference in php5 (and I think I've seen you use some of those :)
--
B.r.K.o.N.j.A = Bionic Robotic Knight Optimized for Nocturnal Judo and
Assasination
Navigation:
[Reply to this message]
|