473,909 Members | 4,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1738
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.ph p";
$xml = new Nessi;
$xml = loadfile(invoic e.xml);
print_r($GLOBAL S);
?>
</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.ph p";
$xml = new Nessi;
$xml = loadfile(invoic e.xml);
print_r($GLOBAL S);
?>
</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.ph p";
$xml = new Nessi;
To instantiate the class Nessi I think it should look like this:
$xml = new Nessi();
>$xml = loadfile(invoic e.xml);
print_r($GLOBA LS);
?>
</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.ph p";
$xml = new Nessi;

To instantiate the class Nessi I think it should look like this:
$xml = new Nessi();
$xml = loadfile(invoic e.xml);
print_r($GLOBAL S);
?>
</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.ph p";
$xml = new Nessi;
$xml = loadfile(invoic e.xml);
print_r($GLOBAL S);
?>
</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.ph p).

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*******@attgl obal.net
=============== ===
Aug 18 '06 #8

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

Similar topics

0
2478
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 html form puts the data in $info if the check box is checked. Part of my php4 script is as follows:
0
2049
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 apache and I get: undefined symbol: gdImagePngCtx I recompiled php4 and included gd and everything works fine. But as soon as I compile gd2 as shared things mess up. I've searched 2 days for a solution, but didn't find anything. Please help me!
1
2094
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 myself in PHP4. Now how do I install that MySQL client in my PHP4 ? Or is is easier/smarter to use another MySQL version, one that IS supported directly by PHP4 ?
2
3268
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 the packaging. I get my packages from stable. Basically, when I tried to install php4-gd2, I get something like this: php4-gd2 depends on zendapi-20040901 I seem to have that (virtual) package already installed however. The only way I...
2
1795
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': /Users/terryrichards/tmp/php-4.3.11/ext/zlib/zlib.c:440: warning: pointer targets in passing argument 1 of 'compress2' differ in signedness .... /Users/terryrichards/tmp/php-4.3.11/ext/session/session.c: In function
0
1706
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 function: pg_connect() No amount of using Synaptic Package Manager would fix this for me. The solution was all at command line under 'root' account: $ apt-get update
0
1297
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 "Regular" PHP scripts work just fine, but the websvn script is acting up - after selecting a repository the page just "hangs", i.e. the browser waits "forever" for a response. If that happens there is no error message in the server log and it looks like...
3
2740
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 support. This seems to be a lot tedious. Anyone with an advic on how to use oracle with php. Im using CentOS4 php4 oracle10g
5
8182
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
2953
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
11346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10538
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7248
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5938
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.