note 102755 added to language.oop5.interfaces
| From: | thanhn2001 at gmail dot com | Date: | Thu, 03 Mar 2011 21:37:46 +0000 |
| Subject: | note 102755 added to language.oop5.interfaces | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177545@lists.php.net to get a copy of this message | ||
PHP prevents interface a contant to be overridden by a class/interface that DIRECTLY inherits it.
However, further inheritance allows it. That means that interface constants are not final as
mentioned in a previous comment. Is this a bug or a feature?
<?php
interface a
{
const b = 'Interface constant';
}
// Prints: Interface constant
echo a::b;
class b implements a
{
}
// This works!!!
class c extends b
{
const b = 'Class constant';
}
echo c::b;
?>
----
Server IP: 69.147.83.197
Probable Submitter: 70.239.149.143
----
Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php
Edit -- https://master.php.net/note/edit/102755
Del: integrated -- https://master.php.net/note/delete/102755/integrated
Del: useless -- https://master.php.net/note/delete/102755/useless
Del: bad code -- https://master.php.net/note/delete/102755/bad+code
Del: spam -- https://master.php.net/note/delete/102755/spam
Del: non-english -- https://master.php.net/note/delete/102755/non-english
Del: in docs -- https://master.php.net/note/delete/102755/in+docs
Del: other reasons-- https://master.php.net/note/delete/102755
Reject -- https://master.php.net/note/reject/102755
Search -- https://master.php.net/manage/user-notes.php