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 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: 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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 29 06:01:29 2024 UTC