Introducing Objects3:45 with Alena Holligan
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.
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 = "firstname.lastname@example.org"; $mail->to = "email@example.com"; $mail->message = "This is the email body"; $mail->send();
Links to more Resources
You need to sign up for Treehouse in order to download course files.Sign up