Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Working within the Object with $this
Lab: Introduction to PHP Object-Oriented Programming (OOP) for WordPress
Video Runtime: 15:41
This episode covers a hard topic for most OOP newbies to grasp: the concept of accessing an object’s internal properties and methods using the PHP reserved pseudo-variable $this
. Each object uses the class blueprint as its code. Within the object itself, you reference that object’s properties and methods using $this
. For example, let’s say you wanted to check the first name on a User object. You would do:
$this->first_name
within the object itself. Look at that code. Internally within the object, the variable $this
refers to the object that you are working with. It’s just that one object and not any of the others.
Externally within the application, you use the variable that represents the object. For example:
$sally = new User();
To view the rest of this write-up, please log in or Go Pro.
Whoever says that coding is hard, just smack them.
Episodes
Total Lab Runtime: 03:04:55
- 1 Lab Introductionfree 08:27
- 2 What is Object-Oriented Programming (OOP)?free 14:14
- 3 What is an object?free 13:30
- 4 Meet the Class Blueprintpro 04:53
- 5 Creating an Objectpro 07:57
- 6 Defining Characteristicspro 10:54
- 7 Putting the Object to Workpro 13:56
- 8 Hiding Away the Complexitypro 22:40
- 9 Working within the Object with $thispro 15:41
- 10 Internal Control of Object Creationpro 15:07
- 11 Class Constantspro 08:58
- 12 Class Staticpro 17:49
- 13 What OOP is Notpro 19:11
- 14 Practical Examplespro 04:52
- 15 Wrap it Uppro 06:46