Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
The scope resolution operator allows access to static, constant, and overridden properties and methods of a class without needing to instantiate an object. I'll cover constants in the next video, and overwriting properties and methods in the next chapter. In the meantime, let's focus on accessing the static address types. The scope resolution operator in code is just a double colon (::). To use this token, you'll need the name of the class, followed by the double colon (::). For a method, just add the name of the static method with parentheses, and whatever arguments are needed. For a property, add a dollar sign ($), then the name of the static property that you're going to be accessing.
Let's use the scope resolution operator to access the static address types. Now, let's switch back to the code, replace the variable address with the class name address, then replace the object property access syntax symbols with a double colon (::). Then finally, prepend valid address types with a dollar sign ($). Save the demo. Then, refresh the browser. Instead of the error, you will see the array of address types. Use of the scope resolution operator is not limited to accessing static properties and methods, as I will demonstrate in the next video.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 92739 Viewers
82 Video lessons · 104201 Viewers
71 Video lessons · 75832 Viewers
56 Video lessons · 107205 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.