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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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: Mon Oct 07 05:01:27 2024 UTC