Home > Backend Development > PHP Tutorial > PHP multiple interfaces with the same method_PHP tutorial

PHP multiple interfaces with the same method_PHP tutorial

WBOY
Release: 2016-07-20 11:17:23
Original
1160 people have browsed it

If there are multiple interfaces with the same method name and they are not inherited, PHP is not allowed

The following examples:

 php;">

interface a{

public function x();

 }

interface b{

public function x();

 }

class c implements a,b{

public function x();

 }

The following error is reported: Can't inherit abstract function b::x() (previously declared abstract in c)

If you want to implement different interfaces with the same method, you can implement it as follows:

 php;">

Interface d{

public function x();

 }

interface a extends d{}

interface b extends d{}

class c implements a,b{

public function x(){

echo "succ";

 }

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371991.htmlTechArticleIf there are multiple interfaces with the same method name and they are not inherited, PHP is not allowed as follows Example: php; interface a{ public function x(); } interface b{ public function x()...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template