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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 01 13:01:33 2024 UTC