In this lesson our instructor talks about object-oriented programming. First, he discuses associative arrays, classes, and defining classes. Then he talks about objects, instantiating classes, and object properties. He ends the lesson with a helpful homework challenge.
Object-oriented programming, or OOP, is a programming paradigm that allows user-defined data types to be
created that model ‘real-world’ objects. Object-oriented programs work with and manipulate these
A class provides a formal description of how a particular real-world object is to be modeled in code. It
is a ‘template’ for a user-defined data type.
A class can describe both the properties a particular type of object has, as well as any functions,
known as methods, that a particular type of object can perform.
Classes are defined in PHP using the class keyword. Class names follow the same rules as variable
names and by convention always have their first letter capitalized. Classes definitions also typically follow the
one-class-per-file convention and have their definition file have the same name as the class.
An object refers to a particular instance of a class data type declared in PHP code.
Creating an object is known as instantiating, or creating an instance, of a class.
The new keyword is used to create an object, or an instance of, a class in PHP.
For objects of a particular class to be instantiated in a PHP script, the class definition file for those
objects must be included or defined somewhere within the script.
An object’s properties can be set or accessed using the -> syntax.
Introduction to Object-Oriented Programming
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.