PHP4 vs PHP5 classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have the following code in part of a loop:
$max = $players->max();

Important parts of players class:
class Players extends dynamicTable {
   var $setup;
   var $lid;
   var $size;
   var $max;
   var $data;
   var $data_result;
   var $data_index;
   var $player_stats_result;
   var $player_stats_data;
   var $player_stats_index;
   var $player_stats_start;
   var $player_type_result;

   function Players($lid) {
      global $prefix, $db;

      /*
       * Find max size of rows
       */

      $this->lid = $lid;
      $this->max=0;
        echo "$this->index";
      $result = $db->sql_query("select * from " . $prefix .
"_league_games_setup where lid = $lid");
      while (($rows = $db->sql_fetchrow($result))) {
         $c=0;
         for ($i=3; $i < 23; $i++) {
          if ($rows[$i] != "")
             $c++;
         }
         if ($c > $this->max)
            $this->max = $c;
      }

      $this->index = 3;
   }


   function max() {
        return ($this->max);


The most important part of this code to me is:
$this->index = 3;
It is important that this is reset to 3 for the rest of the loop to work
properly.
In PHP4, $this->index is reset to 3 each time the loop happens, but in
PHP5 it is not.
It appears that after the first loop, PHP5 seems to "remember" the value
of $this->max and therefore does not enter the Players function to set
$this->index = 3. I have run through the script with a debugger, and sure
enough, we only enter function Players once.

Is this normal behaviour for PHP5 vs PHP4?
Is there a way for me to force $this->max to be calculated each time
function max is called?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux