Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We won't be building our own object, but we will be working with a PDO object, so I want to make sure you’re clear on some of the terminology and syntax involved in working with objects. An object is a complex variable type that bundles other variables and functions together into a single unit. Those variables are called "properties" of the object and those functions are called "methods" of the object. We’ll be utilizing a PHP Data Object (PDO) to connect to our database.
Object Example
In our real world example of this, say the object is a dog. A dog has attributes like gender, weight, and hair color. It also has Actions such as Eating, Sleeping, and Walking. If a dog is the object, then Gender, Weight and Hair Color are Properties and Eating, Sleeping, and Walking are Methods.
Using the PHP Mailer Object:
$mail = new PHPMailer();
$mail->from = "from@example.com";
$mail->to = "to@example.com";
$mail->message = "This is the email body";
$mail->send();
Links to more Resources
PHP Documentation: Classes and Objects
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up