danbeck Tue Mar 27 09:33:36 2001 EDT
Modified files:
/phpdoc/en/functions classobj.xml
Log:
added examples for get_class_* functions
Index: phpdoc/en/functions/classobj.xml
diff -u phpdoc/en/functions/classobj.xml:1.15 phpdoc/en/functions/classobj.xml:1.16
--- phpdoc/en/functions/classobj.xml:1.15 Tue Mar 27 08:07:03 2001
+++ phpdoc/en/functions/classobj.xml Tue Mar 27 09:33:36 2001
@@ -345,6 +345,51 @@
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">
+<?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";
+}
+
+?>
+ </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>
@@ -367,9 +412,56 @@
<paramdef>string <parameter>class_name</parameter></paramdef>
</funcprototype>
</funcsynopsis>
+ <para>
+ 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">
+<?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";
+}
+
+?>
+ </programlisting>
+ </example>
+ </para>
<para>
- This function will return an array of default properties of the
- class.
+ Will produce:
+ <informalexample>
+ <programlisting>
+var2 : xyz
+var3 : 100
+ </programlisting>
+ </informalexample>
</para>
<simpara>
See also <function>get_class_methods</function>,
@@ -404,6 +496,10 @@
<filename>ext/standard/basic_functions.c</filename>)
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>