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,34 +43,10 @@
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>
49
-
<refsect1 role="changelog">
50
-
&reftitle.changelog;
51
-
<para>
52
-
<informaltable>
53
-
<tgroup cols="2">
54
-
<thead>
55
-
<row>
56
-
<entry>&Version;</entry>
57
-
<entry>&Description;</entry>
58
-
</row>
59
-
</thead>
60
-
<tbody>
61
-
<row>
62
-
<entry>5.0.2</entry>
63
-
<entry>
64
-
No longer returns &true; for defined interfaces. Use
65
-
<function>interface_exists</function>.
66
-
</entry>
67
-
</row>
68
-
</tbody>
69
-
</tgroup>
70
-
</informaltable>
71
-
</para>
72
-
</refsect1>
73
50
<refsect1 role="examples">
74
51
&reftitle.examples;
75
52
<para>
...
...
@@ -92,17 +69,16 @@ if (class_exists('MyClass')) {
92
69
<programlisting role="php">
93
70
<![CDATA[
94
71
<?php
95
-
function __autoload($class)
96
-
{
97
-
include($class . '.php');
72
+
spl_autoload_register(function ($class_name) {
73
+
include $class_name . '.php';
98
74

99
75
// Check to see whether the include declared the class
100
-
if (!class_exists($class, false)) {
101
-
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");
102
78
}
103
-
}
79
+
});
104
80

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

...
...
@@ -117,13 +93,13 @@ if (class_exists('MyClass')) {
117
93
<para>
118
94
<simplelist>
119
95
<member><function>function_exists</function></member>
96
+
<member><function>enum_exists</function></member>
120
97
<member><function>interface_exists</function></member>
121
98
<member><function>get_declared_classes</function></member>
122
99
</simplelist>
123
100
</para>
124
101
</refsect1>
125
102
</refentry>
126
-

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