Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

class_exists(3) [php man page]

CLASS_EXISTS(3) 							 1							   CLASS_EXISTS(3)

class_exists - Checks if the class has been defined

SYNOPSIS
bool class_exists (string $class_name, [bool $autoload = true]) DESCRIPTION
This function checks whether or not the given class has been defined. PARAMETERS
o $class_name - The class name. The name is matched in a case-insensitive manner. o $autoload - Whether or not to call __autoload by default. RETURN VALUES
Returns TRUE if $class_name is a defined class, FALSE otherwise. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.0.2 | | | | | | | No longer returns TRUE for defined interfaces. | | | Use interface_exists(3). | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 class_exists(3) example <?php // Check that 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 whether 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
function_exists(3), interface_exists(3), get_declared_classes(3). PHP Documentation Group CLASS_EXISTS(3)

Check Out this Related Man Page

CLASS_IMPLEMENTS(3)							 1						       CLASS_IMPLEMENTS(3)

class_implements - Return the interfaces which are implemented by the given class or interface

SYNOPSIS
array class_implements (mixed $class, [bool $autoload = true]) DESCRIPTION
This function returns an array with the names of the interfaces that the given $class and its parents implement. PARAMETERS
o $class - An object (class instance) or a string (class or interface name). o $autoload - Whether to allow this function to load the class automatically through the __autoload(3) magic method. RETURN VALUES
An array on success, or FALSE on error. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.0 | | | | | | | Added the option to pass the $class parameter as | | | a string. Added the $autoload parameter. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 class_implements(3) example <?php interface foo { } class bar implements foo {} print_r(class_implements(new bar)); // since PHP 5.1.0 you may also specify the parameter as a string print_r(class_implements('bar')); function __autoload($class_name) { require_once $class_name . '.php'; } // use __autoload to load the 'not_loaded' class print_r(class_implements('not_loaded', true)); ?> The above example will output something similar to: Array ( [foo] => foo ) Array ( [interface_of_not_loaded] => interface_of_not_loaded ) SEE ALSO
class_parents(3), get_declared_interfaces(3). PHP Documentation Group CLASS_IMPLEMENTS(3)
Man Page

4 More Discussions You Might Find Interesting

1. Programming

Will we get SEGV if we try to “delete []” un-initialized integer pointer variable.

I have a class with an integer pointer, which I have not initialized to NULL in the constructor. For example: class myclass { private: char * name; int *site; } myclass:: myclass(....) : name(NULL) { ..... } other member function “delete “ the variable before... (2 Replies)
Discussion started by: sureshreddi_ps
2 Replies

2. AIX

sleepless

hi, What's "sleepless 15" and "autoload sleepless" in AIX shell programming? Can't find documentation. Thanks in advance, itik (1 Reply)
Discussion started by: itik
1 Replies

3. UNIX for Advanced & Expert Users

Unable to load interbase.so

Hi I'm trying to add interbase.so to php.ini but i can't, the error says Unable to load ../../.../extensions/interbase.so - libgds.so on ... no such file or directory on line 0 But all the files are created correctly on their folders Any idea? (1 Reply)
Discussion started by: ncatdesigner
1 Replies

4. Shell Programming and Scripting

php class

I was hoping you could help me out? Is it possible to add the ability to choose multiple directions to search within? I can have not figured out how to build the array with the form, something todo with in the value. Any help would be appericated. Index.php <html> <head> <title>DNS... (0 Replies)
Discussion started by: mrlayance
0 Replies