PHP多个接口同个方法
May 19, 2016 pm 12:16 PM
如果有多个接口有一个相同的方法名,且不是继承出来的,PHP是不允许的
如下实例:
interface a{ public function x(); } interface b{ public function x(); } class c implements a,b{ public function x(); }
Copy after login
报如下错误: Can't inherit abstract function b::x() (previously declared abstract in c)
如果要实现不同接口有相同的方法,可以如下实现:
interface d{ public function x(); } interface a extends d{} interface b extends d{} class c implements a,b{ public function x(){ echo "succ"; } }
Copy after login
以上就是PHP多个接口同个方法的内容,更多相关内容请关注PHP中文网(www.php.cn)!
通过腾讯QQ微博API接口获取微博内容
http://tech.cncms.com/web/php/23492.html
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
