php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #331 static variables in object methods broken
Submitted: 1998-04-29 16:49 UTC Modified: 1998-04-29 17:50 UTC
From: jdavis at student dot net Assigned:
Status: Closed Package: Other
PHP Version: 3.0 Release Candidate 4 OS: linux
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: jdavis at student dot net
New email:
PHP Version: OS:

 

 [1998-04-29 16:49 UTC] jdavis at student dot net
sorry if i'm missing something but it would seem that the
following code should output:

1
2
3

instead $a never is set so it doesn't output anyting (except
the "<p>\n" part)

thank you and pls let me know if you need more info
-----

class foobar {

  function init () {   

    static $a=1;

    print $a;
    print "<p>\n";
  
    $a++;
    }
};

$bar = new foobar; $bar->init(); $bar->init();
$bar->init();

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-04-29 17:50 UTC] zeev
Fixed.  My recommendation to usually avoid using it stands.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC