php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36343 Static var inheritence using Parent/child
Submitted: 2006-02-09 17:40 UTC Modified: 2006-02-09 18:05 UTC
From: lordi at msdi dot ca Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.2 OS: Freebsd 6.0
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: lordi at msdi dot ca
New email:
PHP Version: OS:

 

 [2006-02-09 17:40 UTC] lordi at msdi dot ca
Description:
------------
I don't know if it is by design, but this is not what I would expect logically...

Reproduce code:
---------------
<?php
	class A {
		static $var = 'foo';
		
		static function getvar (){
			return self::$var;
		}
	}
	
	class B extends A{
		static $var = 'bar';

	}

	echo A::getvar();
	echo B::getvar();
?>

Expected result:
----------------
foobar

Actual result:
--------------
foofoo

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-09 18:05 UTC] tony2001@php.net
Yes, this is by design.
self:: is resolved during compile time.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 01:01:35 2025 UTC