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

Yes, $my_object is a subclass of MyInterface
Yes, MyClass is a subclass of MyInterface

method_​exists

method_exists — Checks if the class method exists.

bool method_exists ( mixed $object , string $method_name )

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 .

<?php
class myClass {
public $mine;
private $xpto;
static protected $test;
static function test() {
var_dump(property_exists('myClass', 'xpto')); //true
}
}
var_dump(property_exists('myClass', 'mine')); //true
var_dump(property_exists(new myClass, 'mine')); //true
var_dump(property_exists('myClass', 'xpto')); //true, as of PHP 5.3.0
var_dump(property_exists('myClass', 'bar')); //false
var_dump(property_exists('myClass', 'test')); //true, as of PHP 5.3.0
myClass::test();
?>

trait_exists

trait_exists — Checks if the trait exists

bool trait_exists ( string $traitname [, bool $autoload ] )

traitname , autoload .

<?php
trait World {
private static $instance;
protected $tmp;
public static function World()
{
self::$instance = new static();
self::$instance->tmp = get_called_class().' '.__TRAIT__;
return self::$instance;
}
}
if ( trait_exists( 'World' ) ) {
class Hello {
use World;
public function text( $str )
{
return $this->tmp.$str;
}
}
}
echo Hello::World()->text('!!!'); // Hello World!!!