http://www.php.net/manual/en/book.reflection.php
| Function | Description |
|---|---|
| class_exists($class) | Returns TRUE if the specified class has been defined. |
| get_class($object) | Returns the class name of the specified object as a string. |
| is_a($object, $class) | Returns TRUE if the specified object is an instance of the specified class. |
| property_exists($object, $property) | Returns TRUE if the specified object has the specified property. |
| method_exists($object, $method) | Returns TRUE if the specified object has the specified method. |
if (is_a($trumpet, 'Product')) {
// Code to work with a Product object
}
if (property_exists($trumpet, 'price')) {
// Code to work with the price property
}
if (method_exists($trumpet, 'getPrice')) {
// Code to work with the getPrice method
}