<!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>the "Late Static Binding" class name</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.class-exists.html">class_exists</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-class-methods.html">get_class_methods</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-called-class" class="refentry"> <div class="refnamediv"> <h1 class="refname">get_called_class</h1> <p class="verinfo">(PHP 5 >= 5.3.0)</p><p class="refpurpose"><span class="refname">get_called_class</span> — <span class="dc-title">the "Late Static Binding" class name</span></p> </div> <div class="refsect1 description" id="refsect1-function.get-called-class-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>get_called_class</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Gets the name of the class the static method is called in. </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.get-called-class-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the class name. Returns <strong><code>FALSE</code></strong> if called from outside a class. </p> </div> <div class="refsect1 examples" id="refsect1-function.get-called-class-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5047"> <p><strong>Example #1 Using <span class="function"><strong>get_called_class()</strong></span></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">foo </span><span style="color: #007700">{<br /> static public function </span><span style="color: #0000BB">test</span><span style="color: #007700">() {<br /> </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_called_class</span><span style="color: #007700">());<br /> }<br />}<br /><br />class </span><span style="color: #0000BB">bar </span><span style="color: #007700">extends </span><span style="color: #0000BB">foo </span><span style="color: #007700">{<br />}<br /><br /></span><span style="color: #0000BB">foo</span><span style="color: #007700">::</span><span style="color: #0000BB">test</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">bar</span><span style="color: #007700">::</span><span style="color: #0000BB">test</span><span style="color: #007700">();<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> string(3) "foo" string(3) "bar" </pre></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.get-called-class-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.get-parent-class.html" class="function" rel="rdfs-seeAlso">get_parent_class()</a> - Retrieves the parent class name for object or class</span></li> <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.is-subclass-of.html" class="function" rel="rdfs-seeAlso">is_subclass_of()</a> - Checks if the object has this class as one of its parents</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.class-exists.html">class_exists</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.get-class-methods.html">get_class_methods</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>