|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-17 13:33 UTC] Jason at amp-design dot net
[2005-01-17 13:47 UTC] Jason at amp-design dot net
[2005-04-11 13:50 UTC] jbs at fromru dot com
[2005-04-12 13:28 UTC] lsmith@php.net
[2005-04-25 06:24 UTC] php-bugs at foomatic dot net
[2005-04-25 07:49 UTC] helly@php.net
[2005-04-25 10:39 UTC] php-bugs at foomatic dot net
[2005-04-25 21:14 UTC] helly@php.net
[2005-04-27 18:59 UTC] andi@php.net
[2011-02-04 19:50 UTC] tim at gurka dot se
[2012-05-09 10:01 UTC] jeff at goblinoid dot co dot uk
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
Description: ------------ Special keyword 'self' represents the parent class instead of the child class when it is used in an inherited method of the parent class. Reproduce code: --------------- class Foo { const NAME = 'Foo'; static public function display() { echo self::NAME; } static public function getInstance() { $instance = new self; return $instance; } } class Child extends Foo { const NAME = 'Child'; } echo('Class constant: '); Child::display(); echo('<BR>Object class: '); echo(get_class(Child::getInstance())); Expected result: ---------------- Class constant: Child Object class: Child Actual result: -------------- Class constant: Foo Object class: Foo