Unlock your potential with a Pro Membership
Here is where you propel your career forward. Come join us today. Learn more.
Meet the Class Blueprint
Lab: Introduction to PHP Object-Oriented Programming (OOP) for WordPress
Video Runtime: 04:53
The first step is to define our blueprint. In PHP, the keyword class
alerts PHP that this is a blueprint. The syntax is:
class Blueprint_Name { // define the blueprint in here }
An object is a noun, i.e. a thing. Therefore, its name should be a singular noun.
How you code the name varies depending upon if you are following PSR or the WordPress coding standard. Per PSR, class names should be in StudlyCaps, where the words are smooshed together and the first letter is capitalized. Per the WordPress Coding Standard, the words are separated by an underscore and the first letter of each word is capitalized.
The curly braces declare that the class has control over the code that is within them. That code is the blueprint that defines the characteristics and behavior.
Who needs copy/paste? Right. Writing code from scratch is fun!
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