CHAPTER 2Static Variables, Members,and Methods
This chapter discusses the static
keyword as it is applied to variables, classes, and methods. You will learn about the scope resolution operator (::
) and its implication in object-oriented design. Finally, I will touch on the often heated debate about the usage of static classes in application design.
To get the most from this chapter, you should already be familiar with variable scope; that is, you should understand global, function, and class scope, and the use of the $this
variable within classes.
Static Variables
A static variable is a variable that exists only in function scope, but that does not lose its value when the function is finished executing; that is, it remembers its value the next ...
Get Pro PHP: Patterns, Frameworks, Testing and More now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.