note 117679 added to language.oop5.interfaces
| From: | aditycse at gmail dot com | Date: | Tue, 21 Jul 2015 05:50:06 +0000 |
| Subject: | note 117679 added to language.oop5.interfaces | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203147@lists.php.net to get a copy of this message | ||
Solution for overriding interface constants
//we can override interface constants by using abstract class
//if Test Class implements inter1 than we can not override inter1 interface constants
example:
<?php
interface inter1 {
const interface1 = "I am from interface 1";
function foo1();
function bar1();
}
interface inter2 extends inter1 {
function foo2();
function bar2();
}
interface inter3 {
function foo3();
function bar3();
}
interface inter4 {
function foo4();
function bar4();
}
abstract class AbsClass implements inter2 {
}
class Test extends AbsClass implements inter3, inter4 {
const interface1 = "I am from test class";
public function foo1() {
}
public function foo2() {
}
public function foo3() {
}
public function foo4() {
}
public function bar1() {
}
public function bar2() {
}
public function bar3() {
}
public function bar4() {
}
public function display() {
echo inter1::interface1;
echo PHP_EOL;
echo Test::interface1;
}
}
$Obj = new Test();
$Obj->display(); //I am from interface 1 \n I am from test class
----
Server IP: 72.52.91.14
Probable Submitter: 59.162.46.194
----
Manual Page -- http://php.net/manual/en/language.oop5.interfaces.php
Edit -- https://master.php.net/note/edit/117679
Del: integrated -- https://master.php.net/note/delete/117679/integrated
Del: useless -- https://master.php.net/note/delete/117679/useless
Del: bad code -- https://master.php.net/note/delete/117679/bad+code
Del: spam -- https://master.php.net/note/delete/117679/spam
Del: non-english -- https://master.php.net/note/delete/117679/non-english
Del: in docs -- https://master.php.net/note/delete/117679/in+docs
Del: other reasons-- https://master.php.net/note/delete/117679
Reject -- https://master.php.net/note/reject/117679
Search -- https://master.php.net/manage/user-notes.php