Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4733

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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 class method exists</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.is-subclass-of.html">is_subclass_of</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.property-exists.html">property_exists</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.method-exists" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">method_exists</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">method_exists</span> &mdash; <span class="dc-title">Checks if the class method exists</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.method-exists-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>method_exists</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$object</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$method_name</code></span>
   )</div>

  <p class="para rdfs-comment">
   Checks if the class method exists in the given
   <code class="parameter">object</code>.
  </p>
 </div>

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

    
     <dt>
<code class="parameter">object</code></dt>

     <dd>

      <p class="para">
       An object instance or a class name
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">method_name</code></dt>

     <dd>

      <p class="para">
       The method name
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.method-exists-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> if the method given by <code class="parameter">method_name</code>
   has been defined for the given <code class="parameter">object</code>, <strong><code>FALSE</code></strong> 
   otherwise.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.method-exists-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
<p class="para">Using this function will use any registered
<a href="language.oop5.autoload.html" class="link">autoloaders</a> if the class is not already known.</p></p></blockquote>
 </div>


 <div class="refsect1 examples" id="refsect1-function.method-exists-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-6281">
    <p><strong>Example #1 <span class="function"><strong>method_exists()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$directory&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Directory</span><span style="color: #007700">(</span><span style="color: #DD0000">'.'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">method_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$directory</span><span style="color: #007700">,</span><span style="color: #DD0000">'read'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
bool(true)
</pre></div>
    </div>
   </div>
   <div class="example" id="example-6282">
    <p><strong>Example #2 Static <span class="function"><strong>method_exists()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">method_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'Directory'</span><span style="color: #007700">,</span><span style="color: #DD0000">'read'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
bool(true)
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.method-exists-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.function-exists.html" class="function" rel="rdfs-seeAlso">function_exists()</a> - Return TRUE if the given function has been defined</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.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.is-subclass-of.html">is_subclass_of</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.property-exists.html">property_exists</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>