php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #389 Static variable into Class recursiv function
Submitted: 1998-05-20 07:46 UTC Modified: 1998-05-20 17:39 UTC
From: andri at rti-hq dot kharkov dot ua Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0 Release Candidate 4 OS: Linux 2.0.33
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andri at rti-hq dot kharkov dot ua
New email:
PHP Version: OS:

 

 [1998-05-20 07:46 UTC] andri at rti-hq dot kharkov dot ua
Static variable into Class Recursiv function do not work property
Script exsample:

<?
class clss {
var $t;

        function recursiv() {
        static $r = 0;
        $r++;
        echo "$r<BR>\n";
                if ($r < $this->t) {
                $this->recursiv();
                }
        }
}

$n = new clss;
$n->t = 10;
$n->recursiv();
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-05-20 17:39 UTC] zeev
This works exactly as expected.
However, static variables inside member functions should
be avoided, since the same static variable is shared
among ALL instances of the parent class!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC