<!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>Gets the class methods' names</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.get-called-class.html">get_called_class</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-class-vars.html">get_class_vars</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.get-class-methods" class="refentry"> <div class="refnamediv"> <h1 class="refname">get_class_methods</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">get_class_methods</span> — <span class="dc-title">Gets the class methods' names</span></p> </div> <div class="refsect1 description" id="refsect1-function.get-class-methods-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><strong>get_class_methods</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">$class_name</code></span> )</div> <p class="para rdfs-comment"> Gets the class methods names. </p> </div> <div class="refsect1 parameters" id="refsect1-function.get-class-methods-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">class_name</code></em></span> <dd> <p class="para"> The class name or an object instance </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.get-class-methods-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an array of method names defined for the class specified by <em><code class="parameter">class_name</code></em>. In case of an error, it returns <strong><code>NULL</code></strong>. </p> </div> <div class="refsect1 changelog" id="refsect1-function.get-class-methods-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.0.0</td> <td> As of PHP 5, this function returns the name of the methods as they were declared (case-sensitive). In PHP 4 they were lowercased. </td> </tr> <tr> <td>4.0.6</td> <td> The ability of specifying the object itself has been added. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.get-class-methods-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5048"> <p><strong>Example #1 <span class="function"><strong>get_class_methods()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">myclass </span><span style="color: #007700">{<br /> </span><span style="color: #FF8000">// constructor<br /> </span><span style="color: #007700">function </span><span style="color: #0000BB">myclass</span><span style="color: #007700">()<br /> {<br /> return(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /> }<br /><br /> </span><span style="color: #FF8000">// method 1<br /> </span><span style="color: #007700">function </span><span style="color: #0000BB">myfunc1</span><span style="color: #007700">()<br /> {<br /> return(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /> }<br /><br /> </span><span style="color: #FF8000">// method 2<br /> </span><span style="color: #007700">function </span><span style="color: #0000BB">myfunc2</span><span style="color: #007700">()<br /> {<br /> return(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /> }<br />}<br /><br /></span><span style="color: #0000BB">$class_methods </span><span style="color: #007700">= </span><span style="color: #0000BB">get_class_methods</span><span style="color: #007700">(</span><span style="color: #DD0000">'myclass'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// or<br /></span><span style="color: #0000BB">$class_methods </span><span style="color: #007700">= </span><span style="color: #0000BB">get_class_methods</span><span style="color: #007700">(new </span><span style="color: #0000BB">myclass</span><span style="color: #007700">());<br /><br />foreach (</span><span style="color: #0000BB">$class_methods </span><span style="color: #007700">as </span><span style="color: #0000BB">$method_name</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$method_name</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?></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> myclass myfunc1 myfunc2 </pre></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.get-class-methods-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.get-class.html" class="function" rel="rdfs-seeAlso">get_class()</a> - Returns the name of the class of an object</span></li> <li class="member"> <span class="function"><a href="function.get-class-vars.html" class="function" rel="rdfs-seeAlso">get_class_vars()</a> - Get the default properties of the class</span></li> <li class="member"> <span class="function"><a href="function.get-object-vars.html" class="function" rel="rdfs-seeAlso">get_object_vars()</a> - Gets the properties of the given object</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-called-class.html">get_called_class</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-class-vars.html">get_class_vars</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>