language.oop5.interfaces.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 111 行 · 第 1/2 页
HTML
111 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Object Interfaces</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.oop5.abstract.html">Class Abstraction</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.oop5.overloading.html">Overloading</a></div> <div class="up"><a href="language.oop5.html">Classes and Objects (PHP 5)</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="language.oop5.interfaces" class="sect1"> <h2 class="title">Object Interfaces</h2> <p class="para"> Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled. </p> <p class="para"> Interfaces are defined using the interface keyword, in the same way as a standard class, but without any of the methods having their contents defined. </p> <p class="para"> All methods declared in an interface must be public, this is the nature of an interface. </p> <div id="language.oop5.interfaces.implements" class="sect2"> <h3 class="title"><i>implements</i></h3> <p class="para"> To implement an interface, the <i>implements</i> operator is used. All methods in the interface must be implemented within a class; failure to do so will result in a fatal error. Classes may implement more than one interface if desired by separating each interface with a comma. </p> <blockquote><p><b class="note">Note</b>: A class cannot implement two interfaces that share function names, since it would cause ambiguity. <br /> </p></blockquote> <blockquote><p><b class="note">Note</b>: Interfaces can be extended like classes using the <i>extend</i> operator. <br /> </p></blockquote> </div> <div id="language.oop5.interfaces.constants" class="sect2"> <h3 class="title"><i>Constants</i></h3> <p class="para"> Its possible for interfaces to have constants. Interface constants works exactly like <a href="language.oop5.constants.html" class="link">class constants</a>. They cannot be overridden by a class/interface that inherits it. </p> </div>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?