<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Checks if the interface has been defined</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-parent-class.html">get_parent_class</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.is-a.html">is_a</a></div> <div class="up"><a href="ref.classobj.html">Classes/Object Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.interface-exists" class="refentry"> <div class="refnamediv"> <h1 class="refname">interface_exists</h1> <p class="verinfo">(PHP 5 >= 5.0.2)</p><p class="refpurpose"><span class="refname">interface_exists</span> — <span class="dc-title">Checks if the interface has been defined</span></p> </div> <div class="refsect1 description" id="refsect1-function.interface-exists-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>interface_exists</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$interface_name</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$autoload</code><span class="initializer"> = true</span></span> ] )</div> <p class="para rdfs-comment"> Checks if the given interface has been defined. </p> </div> <div class="refsect1 parameters" id="refsect1-function.interface-exists-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">interface_name</code></em></span> <dd> <p class="para"> The interface name </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">autoload</code></em></span> <dd> <p class="para"> Whether to call <a href="language.oop5.autoload.html" class="link">__autoload</a> or not by default. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.interface-exists-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if the interface given by <em><code class="parameter">interface_name</code></em> has been defined, <strong><code>FALSE</code></strong> otherwise. </p> </div> <div class="refsect1 examples" id="refsect1-function.interface-exists-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5057"> <p><strong>Example #1 <span class="function"><strong>interface_exists()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Check the interface exists before trying to use it<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">interface_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'MyInterface'</span><span style="color: #007700">)) {<br /> class </span><span style="color: #0000BB">MyClass </span><span style="color: #007700">implements </span><span style="color: #0000BB">MyInterface<br /> </span><span style="color: #007700">{<br /> </span><span style="color: #FF8000">// Methods<br /> </span><span style="color: #007700">}<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.interface-exists-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.get-declared-interfaces.html" class="function" rel="rdfs-seeAlso">get_declared_interfaces()</a> - Returns an array of all declared interfaces</span></li> <li class="member"> <span class="function"><a href="function.class-implements.html" class="function" rel="rdfs-seeAlso">class_implements()</a> - Return the interfaces which are implemented by the given class</span></li> <li class="member"> <span class="function"><a href="function.class-exists.html" class="function" rel="rdfs-seeAlso">class_exists()</a> - Checks if the class has been defined</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-parent-class.html">get_parent_class</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.is-a.html">is_a</a></div> <div class="up"><a href="ref.classobj.html">Classes/Object Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>