(chimes)…- [Instructor] I hope that you had success…in completing the static references challenge.…Now let me show the solution that I came up with.…The first thing I did was set up for the challenge,…which meant going into challenge_03.php…and grabbing both the Bicycle class and the Unicycle class…and putting those into a new file called challenge_04.php.…Then I can start the different parts of the challenge.…The first thing was to add a new property called…$instance_count to make it a static property,…and also of course I want to make it public…so that it has visibility.…
It's always a best practice…to have visibility in front of these.…I also gave it a good default value, which was zero,…so we'll start this counter at zero,…and every time we create a new instance,…we're going to increment that counter.…We're also going to define a new method.…It's a static method,…I've also said that it should be public.…And it's going to be called create,…so I can call that on either class,…on my Bicycle class or on the subclass.…
Author
Released
11/17/2017- Defining classes
- Calling methods
- Class inheritance
- Extending and overriding classes
- Accessing and controlling access to properties and methods
- Static properties and methods
- Magic methods: constructor, destructor, and clone
- Creating a PHP OOP project
Skill Level Intermediate
Duration
Views
Related Courses
-
PHP: Accessing Databases with PDO and MySQLi
with David Powers3h 47m Intermediate -
Consuming RESTful APIs in PHP with Guzzle
with Justin Yost2h 12m Intermediate
-
Introduction
-
Welcome1m 3s
-
-
1. Overview and Project Setup
-
What is OOP?5m 21s
-
Project setup3m 1s
-
-
2. Object Basics
-
Define a class5m 52s
-
Instances6m 13s
-
Class properties9m 56s
-
Class methods5m 12s
-
Refer to an instance3m 54s
-
-
3. Class Inheritance
-
What is inheritance?3m 26s
-
Define a subclass7m 27s
-
Extend and override7m 7s
-
Challenge: Inheritance3m 11s
-
Solution: Inheritance8m 10s
-
-
4. Object Access Control
-
Visibility modifiers9m 18s
-
Beware of overloading5m 37s
-
Setter and getter methods4m 46s
-
Challenge: Access control2m 51s
-
Solution: Access control8m 33s
-
-
5. Static Properties and Methods
-
The static modifier7m 12s
-
Inherited static behaviors5m 45s
-
Class constants4m 43s
-
Refer to the parent class7m 19s
-
Late static bindings7m 12s
-
Challenge: Static references3m 30s
-
Solution: Static references7m 45s
-
-
6. Magic Methods
-
Constructor method4m 46s
-
Constructor arguments7m 51s
-
Destructor method4m 34s
-
Clone method6m 9s
-
Assignment by reference4m 20s
-
Compare objects4m 8s
-
-
7. A PHP OOP Project
-
Project introduction5m 57s
-
Challenge: The bicycle class2m 53s
-
Solution: The bicycle class6m 36s
-
From instances to HTML6m 46s
-
Read from a CSV file7m 44s
-
Improve parseCSV5m 43s
-
From a CSV file to instances2m 33s
-
-
Conclusion
-
Next steps36s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Solution: Static references