Classes/Object Functions
__autoload
call_user_method_array
call_user_method
class_alias
class_exists
get_called_class
get_class_methods
get_class_vars
get_class
get_declared_classes
get_declared_interfaces
get_declared_traits
get_object_vars
interface_exists
is_a
is_subclass_of
is_subclass_of — Checks if the object has this class as one of its parents or implements it.object
,class_name
,allow_string
Ex. is_subclass_of() using interface example
<?php// Define the Interfaceinterface MyInterface{public function MyFunction();}// Define the class implementation of the interfaceclass MyClass implements MyInterface{public function MyFunction(){return "MyClass Implements MyInterface!";}}// Instantiate the object$my_object = new MyClass;// Works since 5.3.7// Test using the object instance of the classif (is_subclass_of($my_object, 'MyInterface')) {echo "Yes, \$my_object is a subclass of MyInterface\n";} else {echo "No, \$my_object is not a subclass of MyInterface\n";}// Test using a string of the class nameif (is_subclass_of('MyClass', 'MyInterface')) {echo "Yes, MyClass is a subclass of MyInterface\n";} else {echo "No, MyClass is not a subclass of MyInterface\n";}?>Result
|
method_exists
method_exists
— Checks if the class method exists.
|
object
, method_name
. Returns TRUE if the method given by method_name has been defined for the given object, FALSE otherwise
property_exists
property_exists
— Checks if the object or class has a property .
- Returns TRUE if the property exists, FALSE if it doesn’t exist or NULL in case of an error.
|
trait_exists
trait_exists
— Checks if the trait exists
|
traitname
, autoload
.
|
Powered by:
@code4mk