<!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>Return TRUE if the given function 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.func-num-args.html">func_num_args</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-defined-functions.html">get_defined_functions</a></div> <div class="up"><a href="ref.funchand.html">Function handling Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.function-exists" class="refentry"> <div class="refnamediv"> <h1 class="refname">function_exists</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">function_exists</span> — <span class="dc-title">Return <strong><code>TRUE</code></strong> if the given function has been defined</span></p> </div> <div class="refsect1 description" id="refsect1-function.function-exists-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>function_exists</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$function_name</code></span> )</div> <p class="para rdfs-comment"> Checks the list of defined functions, both built-in (internal) and user-defined, for <em><code class="parameter">function_name</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.function-exists-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">function_name</code></em></span> <dd> <p class="para"> The function name, as a string. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.function-exists-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if <em><code class="parameter">function_name</code></em> exists and is a function, <strong><code>FALSE</code></strong> otherwise. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> This function will return <strong><code>FALSE</code></strong> for constructs, such as <span class="function"><a href="function.include-once.html" class="function">include_once</a></span> and <span class="function"><a href="function.echo.html" class="function">echo</a></span>. </p> </p></blockquote> </div> <div class="refsect1 examples" id="refsect1-function.function-exists-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5116"> <p><strong>Example #1 <span class="function"><strong>function_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: #007700">if (</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'imap_open'</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #DD0000">"IMAP functions are available.<br />\n"</span><span style="color: #007700">;<br />} else {<br /> echo </span><span style="color: #DD0000">"IMAP functions are not available.<br />\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.function-exists-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> A function name may exist even if the function itself is unusable due to configuration or compiling options (with the <a href="ref.image.html" class="link">image</a> functions being an example). </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.function-exists-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.method-exists.html" class="function" rel="rdfs-seeAlso">method_exists()</a> - Checks if the class method exists</span></li> <li class="member"> <span class="function"><a href="function.is-callable.html" class="function" rel="rdfs-seeAlso">is_callable()</a> - Verify that the contents of a variable can be called as a function</span></li> <li class="member"> <span class="function"><a href="function.get-defined-functions.html" class="function" rel="rdfs-seeAlso">get_defined_functions()</a> - Returns an array of all defined functions</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> <li class="member"> <span class="function"><a href="function.extension-loaded.html" class="function" rel="rdfs-seeAlso">extension_loaded()</a> - Find out whether an extension is loaded</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.func-num-args.html">func_num_args</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-defined-functions.html">get_defined_functions</a></div> <div class="up"><a href="ref.funchand.html">Function handling Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>