reference/classobj/functions/class-exists.xml
42bd1bfed391b287e55e47fed1b8f8d22a033ee0
...
...
@@ -9,7 +9,7 @@
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
11
<type>bool</type><methodname>class_exists</methodname>
12
-
<methodparam><type>string</type><parameter>class_name</parameter></methodparam>
12
+
<methodparam><type>string</type><parameter>class</parameter></methodparam>
13
13
<methodparam choice="opt"><type>bool</type><parameter>autoload</parameter><initializer>&true;</initializer></methodparam>
14
14
</methodsynopsis>
15
15
<para>
...
...
@@ -21,7 +21,7 @@
21
21
<para>
22
22
<variablelist>
23
23
<varlistentry>
24
-
<term><parameter>class_name</parameter></term>
24
+
<term><parameter>class</parameter></term>
25
25
<listitem>
26
26
<para>
27
27
The class name. The name is matched in a case-insensitive manner.
...
...
@@ -32,7 +32,8 @@
32
32
<term><parameter>autoload</parameter></term>
33
33
<listitem>
34
34
<para>
35
-
Whether or not to call &link.autoload; by default.
35
+
Whether to <link linkend="language.oop5.autoload">autoload</link>
36
+
if not already loaded.
36
37
</para>
37
38
</listitem>
38
39
</varlistentry>
...
...
@@ -42,7 +43,7 @@
42
43
<refsect1 role="returnvalues">
43
44
&reftitle.returnvalues;
44
45
<para>
45
-
Returns &true; if <parameter>class_name</parameter> is a defined class,
46
+
Returns &true; if <parameter>class</parameter> is a defined class,
46
47
&false; otherwise.
47
48
</para>
48
49
</refsect1>
...
...
@@ -68,17 +69,16 @@ if (class_exists('MyClass')) {
68
69
<programlisting role="php">
69
70
<![CDATA[
70
71
<?php
71
-
function __autoload($class)
72
-
{
73
-
include($class . '.php');
72
+
spl_autoload_register(function ($class_name) {
73
+
include $class_name . '.php';
74
74

75
75
// Check to see whether the include declared the class
76
-
if (!class_exists($class, false)) {
77
-
trigger_error("Unable to load class: $class", E_USER_WARNING);
76
+
if (!class_exists($class_name, false)) {
77
+
throw new LogicException("Unable to load class: $class_name");
78
78
}
79
-
}
79
+
});
80
80

81
-
if (class_exists('MyClass')) {
81
+
if (class_exists(MyClass::class)) {
82
82
$myclass = new MyClass();
83
83
}
84
84

...
...
@@ -93,13 +93,13 @@ if (class_exists('MyClass')) {
93
93
<para>
94
94
<simplelist>
95
95
<member><function>function_exists</function></member>
96
+
<member><function>enum_exists</function></member>
96
97
<member><function>interface_exists</function></member>
97
98
<member><function>get_declared_classes</function></member>
98
99
</simplelist>
99
100
</para>
100
101
</refsect1>
101
102
</refentry>
102
-

103
103
<!-- Keep this comment at the end of the file
104
104
Local variables:
105
105
mode: sgml
106
106