mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 10:58:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@162511 c90b9560-bf6c-de11-be94-00142212c4b1
81 lines
2.3 KiB
XML
81 lines
2.3 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.5 $ -->
|
|
<!-- splitted from ./en/functions/classobj.xml, last change in rev 1.11 -->
|
|
<refentry id="function.class-exists">
|
|
<refnamediv>
|
|
<refname>class_exists</refname>
|
|
<refpurpose>Checks if the class has been defined</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<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 parameter <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>.
|
|
</simpara>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|