|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
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:


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";

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1998-04-29 17:50 UTC] zeev
Fixed.  My recommendation to usually avoid using it stands.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon May 29 09:03:40 2023 UTC