downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.function-exists.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.funchand.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.function-exists.php',
   
1 => 'function_exists',
  ),
 
'up' =>
  array (
   
0 => 'ref.funchand.php',
   
1 => 'Function handling Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.func-num-args.php',
   
1 => 'func_num_args',
  ),
 
'next' =>
  array (
   
0 => 'function.get-defined-functions.php',
   
1 => 'get_defined_functions',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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> &mdash; <span class="dc-title">Return <b><tt class="constant">TRUE</tt></b> if the given function has been defined</span></p>

 </div>
 
 <a name="function.function-exists.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>function_exists</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$function_name</tt></span>
   )</div>

  <p class="para rdfs-comment">
   Checks the list of defined functions, both built-in (internal) and
   user-defined, for <i><tt class="parameter">function_name</tt></i>
.
  </p>
 </div>


 <a name="function.function-exists.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">function_name</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The function name, as a string.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.function-exists.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> if <i><tt class="parameter">function_name</tt></i>
 exists and is a
   function, <b><tt class="constant">FALSE</tt></b> otherwise.
  </p>
  <blockquote><p><b class="note">Note</b>:
  
    This function will return <b><tt class="constant">FALSE</tt></b> for constructs, such as
    <a href="function.include-once.php" class="function">include_once()</a> and <a href="function.echo.php" class="function">echo()</a>.
   <br />
  </p></blockquote>
 </div>


 <a name="function.function-exists.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>function_exists()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">function_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'imap_open'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"IMAP&nbsp;functions&nbsp;are&nbsp;available.&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"IMAP&nbsp;functions&nbsp;are&nbsp;not&nbsp;available.&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.function-exists.notes"></a><div class="refsect1 notes">
  <h3 class="title">Notes</h3>
  <blockquote><p><b class="note">Note</b>:
  
    A function name may exist even if the function itself is unusable due to
    configuration or compiling options (with the <a href="ref.image.php" class="link">image</a> functions being an example).
   <br />
  </p></blockquote>
 </div>


 <a name="function.function-exists.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.method-exists.php" class="function" rel="rdfs-seeAlso">method_exists()</a> - Checks if the class method exists</li>
    <li class="member"><a href="function.is-callable.php" class="function" rel="rdfs-seeAlso">is_callable()</a> - Verify that the contents of a variable can be called as a function</li>
    <li class="member"><a href="function.get-defined-functions.php" class="function" rel="rdfs-seeAlso">get_defined_functions()</a> - Returns an array of all defined functions</li>
   </ul><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites