Reply to PHP4 -> PHP5 issue

Your name:

Reply:


Posted by Mathieu Maes on 08/17/06 13:43

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 ?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация