Web Analytics Made Easy -
StatCounter Possible PHP4 Compatibility Issue - CodingForum

Announcement

Collapse
No announcement yet.

Possible PHP4 Compatibility Issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible PHP4 Compatibility Issue

    The attached code works fine on my localhost apache webserver running PHP5, but when the site is uploaded to and used on my web space, the object property "$this -> alldetails" is not defined and results in these errors whenever "makeMenu()" is called. As the code executes fine on PHP5 and not on PHP4, my only explanantion for this error is a compatibility issue I have missed. Please could someone check this code and see if I have missed anything?

    My Server: Apache 2.0.48 Running PHP 5.0.4
    Host's Server: Apache 2 Running PHP 4.3.8
    Attached Files

  • #2
    You need to declare additional vars. I am surprised it worked in PHP 5, must have built in support for assuming you 'meant' to declare a variable beforehand.
    PHP Code:
     var $parent;
     var 
    $depth;
     var 
    $file;
    var 
    $alldetails;
    var 
    $baseurl;
    var 
    $category;
     function 
    Menu($file){
      
    $this -> parent "";
      
    $this -> depth 0;
      
    $this -> category "general";
      
    $this -> file $file;
      
    $this -> baseurl "";  
      
    $this -> alldetails null;
      
    $xml_parser xml_parser_create();
      
    xml_set_element_handler($xml_parser, array($this,"startElement"), array($this,"endElement"));
      
    xml_parse($xml_parser,file_get_contents($this -> file),true);
      
    xml_parser_free($xml_parser);
      } 
    Whats the point of a signature?

    Comment


    • #3
      should not make a difference but what happens if you change

      $this -> alldetails = null;

      to

      $this -> alldetails = array();

      the declaration (or lack of) should make no difference.

      also in general for php4 at least its much more efficient to dereference class variables before you use them in loops etc ...

      $alldetails = $this->alldetails;
      foreach( $alldetails as $etc ....
      Last edited by firepages; Aug 5, 2005, 10:37 PM.
      resistance is...

      MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

      Comment

      Working...
      X