php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5242 wrong variable value in recoursive functions declared as object method
Submitted: 2000-06-28 07:56 UTC Modified: 2000-08-01 23:01 UTC
From: marco at gsol dot it Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.0 Release OS: RH Linux 6.1 - apache 1.3.12
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marco at gsol dot it
New email:
PHP Version: OS:

 

 [2000-06-28 07:56 UTC] marco at gsol dot it
<?php
class Menu {

  function printfield($Active, $Level, $Value, $Link) {
    [...]
  }

  function printchilds($Parents, $Active=0, $Level=0, $Parent=0) {
    $name=$this->that_class;
    $q = new $name;

    $q->query('select ID,Expand,Value,Link from ' . $this->table . ' where GID=' . $Parent . ' and En=1 order by Sort');

    while($q->next_record()) {
      $ID=$q->f(0);
      $Expand=intval($q->f(1));
      $Value=htmlentities($q->f(2));
      $Link=$q->f(3);

      $this->printfield($Active==$ID, $Level, $Value, $Link);

      if (!$Expand) {
        if ($ID==$Active)
          $Expand=true;
        else
          for ($i=0;isset($Parents[$i]);++$i)
            $Expand=$Expand || ($Parents[$i]==$ID);
      }
      if ($Expand)
        $this->printchilds($Parents, $Active, $Level+1, $ID);        # Recoursive call
    }
  }
}
?>

$Parent variable assumes other variables values instead $ID value

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-04 15:58 UTC] stas at cvs dot php dot net
Could you please explain what's wrong and bring *reproducible* (like, without database calls) and short example?
 [2000-08-01 23:01 UTC] waldschrott@php.net
no feedback, closed
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 13:00:01 2026 UTC