PHP: class_exists - Manual in Deutsh
PHP: class_exists - Manual in French
PHP: class_exists - Manual in Polish

You Are At PHP: class_exists - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

class_exists

(PHP 4, PHP 5)

class_exists -- Checks if the class has been defined

Description

bool class_exists ( string class_name [, bool autoload] )

This function checks if the given class have been defined.

Parameters

class_name

The class name

autoload

Whether to call __autoload or not by default

Return Values

Returns TRUE if class_name is a defined class, FALSE otherwise.

ChangeLog

VersionDescription
5.0.0 The autoload was added.

Examples

Example 1. class_exists() example

<?php
// Check the class exists before trying to use it
if (class_exists('MyClass')) {
    
$myclass = new MyClass();
}

?>

Example 2. autoload parameter example

<?php
function __autoload($class)
{
    include(
$class . '.php');

    
// Check to see if the include declared the class
    
if (!class_exists($class, false)) {
        
trigger_error("Unable to load class: $class", E_USER_WARNING);
    }
}

if (
class_exists('MyClass')) {
    
$myclass = new MyClass();
}

?>

See Also

interface_exists()
get_declared_classes()

Numizmatyka
Agencja Reklamowa Katowice
analizy
banki kredyty
salon

Another Useful functions:


zend-macro.z-obj-class-name-p | zend-api.zend-update-class-constants | zend-api.zend-u-lookup-class | zend-api.zend-u-lookup-class-ex | zend-api.zend-u-fetch-class | zend-api.zend-register-internal-class | zend-api.zend-register-internal-class-ex | zend-api.zend-register-default-classes | zend-api.zend-lookup-class | zend-api.zend-initialize-class-data | zend-api.zend-get-object-classname | zend-api.zend-get-class-entry | zend-api.zend-fetch-class | zend-api.zend-disable-class | zend-api.zend-declare-class-constant | zend-api.zend-declare-class-constant-stringl | zend-api.zend-declare-class-constant-string | zend-api.zend-declare-class-constant-long | zend-api.zend-declare-class-constant-double | zend-api.zend-declare-class-constant-bool | zend-api.zend-cleanup-class-data | zend-api.zend-class-implements | zend-api.get-active-class-name | zend-api.do-bind-inherited-class | zend-api.do-bind-class | zend-api.destroy-zend-class | reserved.classes | ref.classobj | ref.classkit | migration52.classes | migration52.class-constants | function.spl-classes | function.soap-soapserver-setclass | function.runkit-class-emancipate | function.runkit-class-adopt | function.mcal-event-set-class | function.is-subclass-of | function.get-parent-class | function.get-declared-classes | function.get-class | function.get-class-vars | function.get-class-methods | function.dom-domdocument-registernodeclass | function.classkit-method-rename | function.classkit-method-remove | function.classkit-method-redefine | function.classkit-method-copy | function.classkit-method-add | function.classkit-import | function.class-parents | function.class-implements | function.class-exists | function.bcompiler-write-class | function.bcompiler-parse-class | | class.variant | class.dotnet | class.dir | class.com |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.