473,246 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

PHP4 -> PHP5 issue

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 :

Expand|Select|Wrap|Line Numbers
  1. Class Nessi
  2. {
  3. // ident part
  4. var $user = ""; //the username
  5. var $password = ""; //the password
  6.  
  7. // invoice records
  8. var $invoices = array(); //list of invoice records
  9. var $i = -1; //invoice counter
  10.  
  11. // client records
  12. var $clients = array(); //list of client records
  13. var $j = -1; //client counter
  14.  
  15. var $XML = ""; // The XML file content
  16. function OpenFile($filename)
  17. {
  18. // leest de inhoud van een bestand naar een string
  19. $handle = fopen ($filename, "r");
  20. $contents = fread ($handle, filesize ($filename));
  21. fclose ($handle);
  22. $this->XML = $contents;
  23. $this->ParseXML();
  24. }
  25.  
  26. function ParseXML()
  27. {
  28. $doc = xmldoc($this->XML);
  29. $root = $doc->root();
  30. $children = $root->children();
  31.  
  32. foreach($children as $child)
  33. {
  34. if ($child->type == "1")
  35. {
  36. switch ($child->tagname)
  37. {
  38. case "ident":
  39. $this->Ident($child);
  40. break;
  41. case "invoice":
  42. $this->Invoice($child);
  43. break;
  44. case "client":
  45. $this->Client($child);
  46. break;
  47. default: ;
  48. } // switch
  49. }
  50. }
  51. unset($this->XML);
  52. }
  53.  
  54. function Ident($child)
  55. {
  56. $record = $child->children();
  57.  
  58. foreach($record as $item)
  59. {
  60. if ($item->type == "1")
  61. {
  62. if ($item->tagname == "user")
  63. {
  64. $content = $item->children();
  65. $this->user = $content[0]->content;
  66. }
  67. if ($item->tagname == "pass")
  68. {
  69. $content = $item->children();
  70. $this->password = $content[0]->content;
  71. }
  72. }
  73. }
  74. }
  75.  
  76. function Invoice($child)
  77. {
  78. $i = 0;
  79. $this->invoices[++$this->i] = array();
  80. $invoice = $child->children();
  81. foreach($invoice as $invitem)
  82. {
  83. switch ($invitem->tagname)
  84. {
  85. case "header":
  86. $header = $invitem->children();
  87. foreach($header as $headitem)
  88. {
  89. switch ($headitem->tagname)
  90. {
  91. case "clientid" :
  92. $text = $headitem->children();
  93. $this->invoices[$this->i]['clientid'] =
  94. $text[0]->content;
  95. break;
  96. case "clientinfo":
  97. $text = $headitem->children();
  98. $this->invoices[$this->i]['clientinfo']
  99. = $text[0]->content;
  100. break;
  101. case "date":
  102. $text = $headitem->children();
  103. $this->invoices[$this->i]['date'] =
  104. $text[0]->content;
  105. break;
  106. default: ;
  107. } // switch
  108. }
  109.  
  110. break;
  111. case "items":
  112. $items = $invitem->children();
  113. foreach($items as $item)
  114. {
  115. if ($item->type == "1")
  116. {
  117. if ($item->tagname == "item")
  118. {
  119. $content = $item->children();
  120. $newitem['desc'] =
  121. $content[0]->content;
  122. $newitem['price'] =
  123. $item->get_attribute("price");
  124.  
  125. $this->invoices[$this->i]['items'][$i++] = $newitem;
  126. unset($newitem);
  127. }
  128. }
  129. }
  130. break;
  131. default: ;
  132. } // switch
  133. }
  134. }
  135. function Client($child)
  136. {
  137. // not yet implemented...
  138. }
  139. }
  140.  
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 ?

Aug 17 '06 #1
7 1706
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 :

Expand|Select|Wrap|Line Numbers
  1. Class Nessi
  2. {
  3.     // ident part
  4.     var $user = ""; //the username
  5.     var $password = ""; //the password
  6.     // invoice records
  7.     var $invoices = array(); //list of invoice records
  8.     var $i = -1; //invoice counter
  9.     // client records
  10.     var $clients = array(); //list of client records
  11.     var $j = -1; //client counter
  12.     var $XML = ""; // The XML file content
  13.     function OpenFile($filename)
  14.     {
  15.         // leest de inhoud van een bestand naar een string
  16.         $handle = fopen ($filename, "r");
  17.         $contents = fread ($handle, filesize ($filename));
  18.         fclose ($handle);
  19.         $this->XML = $contents;
  20.         $this->ParseXML();
  21.     }
  22.     function ParseXML()
  23.     {
  24.         $doc = xmldoc($this->XML);
  25.         $root = $doc->root();
  26.         $children = $root->children();
  27.         foreach($children as $child)
  28.         {
  29.             if ($child->type == "1")
  30.             {
  31.                 switch ($child->tagname)
  32.                 {
  33.                     case "ident":
  34.                         $this->Ident($child);
  35.                         break;
  36.                     case "invoice":
  37.                         $this->Invoice($child);
  38.                         break;
  39.                     case "client":
  40.                         $this->Client($child);
  41.                         break;
  42.                     default: ;
  43.                 } // switch
  44.             }
  45.         }
  46.         unset($this->XML);
  47.     }
  48.     function Ident($child)
  49.     {
  50.         $record = $child->children();
  51.         foreach($record as $item)
  52.         {
  53.             if ($item->type == "1")
  54.             {
  55.                 if ($item->tagname == "user")
  56.                 {
  57.                     $content = $item->children();
  58.                     $this->user = $content[0]->content;
  59.                 }
  60.                 if ($item->tagname == "pass")
  61.                 {
  62.                     $content = $item->children();
  63.                     $this->password = $content[0]->content;
  64.                 }
  65.             }
  66.         }
  67.     }
  68.     function Invoice($child)
  69.     {
  70.         $i = 0;
  71.         $this->invoices[++$this->i] = array();
  72.         $invoice = $child->children();
  73.         foreach($invoice as $invitem)
  74.         {
  75.             switch ($invitem->tagname)
  76.             {
  77.                 case "header":
  78.                     $header = $invitem->children();
  79.                     foreach($header as $headitem)
  80.                     {
  81.                         switch ($headitem->tagname)
  82.                         {
  83.                             case "clientid" :
  84.                                 $text = $headitem->children();
  85.                                 $this->invoices[$this->i]['clientid'] =
  86. $text[0]->content;
  87.                                 break;
  88.                             case "clientinfo":
  89.                                 $text = $headitem->children();
  90.                                 $this->invoices[$this->i]['clientinfo']
  91. = $text[0]->content;
  92.                                 break;
  93.                             case "date":
  94.                                 $text = $headitem->children();
  95.                                 $this->invoices[$this->i]['date'] =
  96. $text[0]->content;
  97.                                 break;
  98.                             default: ;
  99.                         } // switch
  100.                     }
  101.                     break;
  102.                 case "items":
  103.                     $items = $invitem->children();
  104.                     foreach($items as $item)
  105.                     {
  106.                         if ($item->type == "1")
  107.                         {
  108.                             if ($item->tagname == "item")
  109.                             {
  110.                                 $content = $item->children();
  111.                                 $newitem['desc'] =
  112. $content[0]->content;
  113.                                 $newitem['price'] =
  114. $item->get_attribute("price");
  115. $this->invoices[$this->i]['items'][$i++] = $newitem;
  116.                                 unset($newitem);
  117.                             }
  118.                         }
  119.                     }
  120.                     break;
  121.                 default: ;
  122.             } // switch
  123.         }
  124.     }
  125.     function Client($child)
  126.     {
  127.         // not yet implemented...
  128.     }
  129. }
  130.  

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
Aug 17 '06 #2
Is there something in an errorlog (if that is turned on in php.ini)?
Aug 17 '06 #3

Dikkie Dik wrote:
Is there something in an errorlog (if that is turned on in php.ini)?
all errors are usually logged in a file as well... Nothing in there.

This is the script how I use the class :
=======
<pre>
<?php
require "nessi.class.php";
$xml = new Nessi;
$xml = loadfile(invoice.xml);
print_r($GLOBALS);
?>
</pre>
=======

The output of the script is :
<pre>
I really haven't got a clue ...

Aug 17 '06 #4
Does the nessi class code start with <?php ? It may start with <? while
short tags are not configured in php.ini

Mathieu Maes wrote:
Dikkie Dik wrote:
>Is there something in an errorlog (if that is turned on in php.ini)?

all errors are usually logged in a file as well... Nothing in there.

This is the script how I use the class :
=======
<pre>
<?php
require "nessi.class.php";
$xml = new Nessi;
$xml = loadfile(invoice.xml);
print_r($GLOBALS);
?>
</pre>
=======

The output of the script is :
<pre>
I really haven't got a clue ...
Aug 17 '06 #5
Dikkie Dik wrote:
Does the nessi class code start with <?php ? It may start with <? while
short tags are not configured in php.ini

Mathieu Maes wrote:
>Dikkie Dik wrote:
>>Is there something in an errorlog (if that is turned on in php.ini)?

all errors are usually logged in a file as well... Nothing in there.

This is the script how I use the class :
=======
<pre>
<?php
require "nessi.class.php";
$xml = new Nessi;
To instantiate the class Nessi I think it should look like this:
$xml = new Nessi();
>$xml = loadfile(invoice.xml);
print_r($GLOBALS);
?>
</pre>
=======

The output of the script is :
<pre>
I really haven't got a clue ...

--
--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Aug 18 '06 #6
I think this is a server configuration problem.

I usually use <?php ?>, but now I tried with <? ?>. Now the code is
just shown in the output in stead of parsed...

Thanks for all your efforts !

IchBin wrote:
Dikkie Dik wrote:
Does the nessi class code start with <?php ? It may start with <? while
short tags are not configured in php.ini

Mathieu Maes wrote:
Dikkie Dik wrote:
Is there something in an errorlog (if that is turned on in php.ini)?

all errors are usually logged in a file as well... Nothing in there.

This is the script how I use the class :
=======
<pre>
<?php
require "nessi.class.php";
$xml = new Nessi;

To instantiate the class Nessi I think it should look like this:
$xml = new Nessi();
$xml = loadfile(invoice.xml);
print_r($GLOBALS);
?>
</pre>
=======

The output of the script is :
<pre>
I really haven't got a clue ...


--
--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Aug 18 '06 #7
Mathieu Maes wrote:
Dikkie Dik wrote:
>>Is there something in an errorlog (if that is turned on in php.ini)?


all errors are usually logged in a file as well... Nothing in there.

This is the script how I use the class :
=======
<pre>
<?php
require "nessi.class.php";
$xml = new Nessi;
$xml = loadfile(invoice.xml);
print_r($GLOBALS);
?>
</pre>
=======

The output of the script is :
<pre>
I really haven't got a clue ...
This generally means you have an error in the required file
(nessi.class.php).

Ensure you have all errors enabled and displayed, or check your error
log (often times the server error log) for errors.

I suspect you'll find an error in the class file.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 18 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nisha_tm | last post by:
Hello: I have a form in which I have checkboxes. Right now, I wrote the form's html and the php4 script. I use associative arrays in the form to capture the checkboxes that are checked. My...
0
by: Klaus Boehmer | last post by:
Hello, I'm trying to install gd2 with gif-support as an extension with php4. I compiled the patched version of gd2 - fine. I compiled php4 with gd=shared - fine. I installed it and restarted...
1
by: Erik | last post by:
I understand, that PHP4 has a MySQL client built in. I was warned, that this client does not support the MySQL 4.1.1 system, which I installed on my RH9 box end that I need to install that version...
2
by: Brad Shinoda | last post by:
I've been running apache and PHP by using apt-get packages for a long time now, and it's been working fine for me. But the other day I tried to get image functions working and hit a brick wall with...
2
by: Terry Richards | last post by:
i am getting lots of errors such as:"...differs in signedness" what is it from? /Users/terryrichards/tmp/php-4.3.11/ext/zlib/zlib.c: In function 'zif_gzcompress':...
0
by: Google Mike | last post by:
I found some strange kind of mild install bug when installing Ubuntu 5.04 php4-pgsql module (the module that connects PHP4 to PostgreSQL). You may encounter the error: Call to undefined...
0
by: FrankL | last post by:
I had to update my server configuration consisting of Apache2 and PHP4. I now have installed: apache2/apache2-prefork 2.0.54-2.1 apache-mod_php4/php4-zlib/php4 4.3.11-0.3.1 ...
3
by: danish | last post by:
Hi, Can anyone tell me how to access oracle from php. Im using CentOS 4 with php4 already installed. From what I found after a bit of googling...php will have to be recompiled with oracle...
5
by: danish | last post by:
I download the oci-1.2.2.tgz file and generated the oci8.so file. After adding the extension=oci8.so in php.ini I get the error unable to load dynamic library /usr/lib/php4/oci8.so
3
by: doctorhardik | last post by:
hai all i am try configure php4.3.9 on my FC-3 machine. and my mysql database version 5.0.1, in phpinfo file it show mysql but when i run php -v command it show error like
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.