curt            Thu Jul  1 23:03:52 2004 EDT

  Modified files:              
    /phpdoc/en/reference/classobj/functions     class-exists.xml 
  Log:
  Define php5 autoload behaviour, Closes bug #28333. And Example.
  
  
http://cvs.php.net/diff.php/phpdoc/en/reference/classobj/functions/class-exists.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/classobj/functions/class-exists.xml
diff -u phpdoc/en/reference/classobj/functions/class-exists.xml:1.3 
phpdoc/en/reference/classobj/functions/class-exists.xml:1.4
--- phpdoc/en/reference/classobj/functions/class-exists.xml:1.3 Mon Oct 21 09:41:39 
2002
+++ phpdoc/en/reference/classobj/functions/class-exists.xml     Thu Jul  1 23:03:52 
2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
 <!-- splitted from ./en/functions/classobj.xml, last change in rev 1.11 -->
   <refentry id="function.class-exists">
    <refnamediv>
@@ -11,11 +11,47 @@
      <methodsynopsis>
       <type>bool</type><methodname>class_exists</methodname>
       <methodparam><type>string</type><parameter>class_name</parameter></methodparam>
+      <methodparam 
choice="opt"><type>bool</type><parameter>autoload</parameter></methodparam>
      </methodsynopsis>
+    <note>
+     <para>
+      The <parameter>autoload</parameter> parameter was added in PHP 5
+     </para>
+    </note>
     <para>
      This function returns &true; if the class given by
      <parameter>class_name</parameter> has been defined,
      &false; otherwise.
+    </para>
+    <para>
+    <function>class_exists</function> will attempt to call __autoload by
+    default, if you don't want <function>class_exists</function> to 
+    call __autoload(), you can set the paramater <parameter>autoload</parameter>
+    to &false;.
+    </para>
+    <para>
+     <example>
+      <title><parameter>autoload</parameter> parameter example</title>
+      <programlisting role="php">
+<![CDATA[
+<?php
+    function __autoload($class) {
+        include($class . '.php');
+
+        /* Check to see it the include defined the class */
+        if ( !class_exists($class, false) ) {
+           trigger_error("Unable to load class $class", E_USER_ERROR);
+        }
+    }
+    
+    if( class_exists('MyClass') ) {
+        $myclass = new MyClass();
+    }
+
+?>
+]]>
+      </programlisting>
+     </example>
     </para>
     <simpara>
      See also <function>get_declared_classes</function>.

Reply via email to