PHP with MySQL Beoyond the Basics
Chapter 3: Introduction to Object-Oriented Programming (OOP)
This chapter covers the beginnings of object-oriented programming.
Exericses
- Defining Classes
- The class created has no information, it's just been created. The page displays the results of
class_exists()
on a class that has been created and one that hasn't. The other method learned wasget_declared_classes()
, which shows all declared classes. - Defining Class Methods
- The page simply displays the results of
get_class_metohds
andmethod_exists
. - Instantiating a Class
- The page displays using
get_class
,is_a
, and calling methods. - Referencing an Instance
- The page displays code that called
$this
to reference the instance.$this
was utilized in theget_class()
function as well as in thehello()
method, which simply calls thesay_hello()
method. - Defining Class Properties
- Simple calling functions and creating and setting instance variables. The exercise also included getting all the class vairables and using
property_exists()
.