|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42681 Static variables in sub/superclasses
Submitted: 2007-09-16 03:36 UTC Modified: 2007-12-06 13:47 UTC
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:2 (50.0%)
From: alex94040 at yahoo dot com Assigned: helly (profile)
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.4 OS: *
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.
Bug Type:
From: alex94040 at yahoo dot com
New email:
PHP Version: OS:


 [2007-09-16 03:36 UTC] alex94040 at yahoo dot com
This is a reactivation of bug 28442; that bug shows as "fixed/closed", but the issue still repros. 

We need to be able to redefine static members of classes (including constants), and set them independently.

Reproduce code:
class ClassA
   private  static   $cn;

   public static function setName( $cn )
      self::$cn   = $cn;

   public static function  getName( )
      return self::$cn;

class ClassB extends ClassA
   private  static   $cn; // with or without this, result is the same

ClassA::setName( 'AAA' );
ClassB::setName( 'BBB' );

print( ClassA::getName() . "\n" ); // prints 'BBB'
print( ClassB::getName() . "\n" ); // prints 'BBB'

Expected result:
Result should read "AAA BBB"

Actual result:
Result actually reads "BBB BBB"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-18 10:44 UTC]
Marcus, can you reply to this please?
 [2007-12-06 13:47 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

This is different from 28442. In fact the static variables are different here as 28442 proves. However you are only using one of them. You need to wait for LSB to make it into PHP and use the new syntax then. This will most likely be solved in 5.3.0.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 01:01:27 2024 UTC