O'Reilly logo

Pro PHP: Patterns, Frameworks, Testing and More by Kevin McArthur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required