6.7. Static Class Members
Static class members are different from regular class members: They don't relate to an object instance of the class, but to the class itself. They are used to implement functionality and data that the class should encapsulate but that does not belong to any particular object. As with regular class members, there are static methods and static properties.
Static properties contain data that should be encapsulated in a class but that should be shared among all class instances. Practically, static class properties are very similar to global variables, except that they belong to a certain class and can be access-restricted.
We already used a static property in Listing 6.3: Counter::$count is a static property. It belongs ...
Get Core PHP Programming, Third Edition 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.