Object-Oriented PHP
Class and Object Methods

Remember when we covered built-in functions in PHP? Well, we can combine that idea with our knowledge of classes and objects: that is, there are built-in PHP functions that tell us interesting information about the classes and objects we've created!

Check out the example in the editor to the right. We're demoing three useful built-in methods: is_a(), which we use to find out if a particular object is an instance of a given class; property_exists(), to see if an object has a given property; and method_exists(), to see if an object has a given method.

Note that the first argument is the object we're checking, and the second is the class, property, or method name as a "string".


Make sense? Awesome! Click Save & Submit Code when you're ready to move on.

View Preview