added examples for get_class_* functions

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@44411 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Beckham 2001-03-27 17:33:36 +00:00
parent f6f5a0cd14
commit d73d10f9db

View file

@ -345,6 +345,51 @@ call_user_method ("print_info", $cntry, "\t");
This function returns an array of method names defined for the
class specified by <parameter>class_name</parameter>.
</para>
<para>
<example>
<title><function>get_class_methods</function> example</title>
<programlisting role="php">
&lt;?php
class myclass {
// constructor
function myclass() {
return(true);
}
// method 1
function myfunc1() {
return(true);
}
// method 2
function myfunc2() {
return(true);
}
}
$my_class = new myclass();
$class_methods = get_class_methods(get_class($my_class));
foreach ($class_methods as $method_name) {
echo "$method_name\n";
}
?&gt;
</programlisting>
</example>
</para>
<para>
Will produce:
<informalexample>
<programlisting>
myclass
myfunc1
myfunc2
</programlisting>
</informalexample>
</para>
<simpara>
See also <function>get_class_vars</function>,
<function>get_object_vars</function>
@ -368,8 +413,55 @@ call_user_method (&quot;print_info&quot;, $cntry, &quot;\t&quot;);
</funcprototype>
</funcsynopsis>
<para>
This function will return an array of default properties of the
class.
This function will return an associative array of default
properties of the class. The resulting array elements are in the
form of <parameter>varname => value</parameter>.
</para>
<note>
<para>
Uninitialized class variables will not be reported by
<function>get_class_vars</function>.
</para>
</note>
<para>
<example>
<title><function>get_class_vars</function> example</title>
<programlisting role="php">
&lt;?php
class myclass {
var $var1; // this has no default value...
var $var2 = "xyz";
var $var3 = 100;
// constructor
function myclass() {
return(true);
}
}
$my_class = new myclass();
$class_vars = get_class_vars(get_class($my_class));
foreach ($class_vars as $name => $value) {
echo "$name : $value\n";
}
?&gt;
</programlisting>
</example>
</para>
<para>
Will produce:
<informalexample>
<programlisting>
var2 : xyz
var3 : 100
</programlisting>
</informalexample>
</para>
<simpara>
See also <function>get_class_methods</function>,
@ -405,6 +497,10 @@ call_user_method (&quot;print_info&quot;, $cntry, &quot;\t&quot;);
and <classname>Directory</classname>
(defined in <filename>ext/standard/dir.c</filename>).
</para>
<para>
Also note that depending on what libraries you have compiled
into PHP, additional classes could be present.
</para>
</note>
</refsect1>
</refentry>