HomePHP Understanding Static Properties with PHP 5
Understanding Static Properties with PHP 5
The powerful object model offered by PHP 5 presents some useful features that are quite frequently underestimated by the average PHP developer. This is precisely the case with using static methods and properties in conjunction with the object-oriented paradigm, thus if you're interested in learning how to put static data to work for you, then this series of articles might be what you're looking for.
Welcome to the second part of the series that began with "Handling Static Data with PHP 5". As you might guess, this series shows you how to take advantage of defining static properties and methods with PHP 5 classes, and it complements the corresponding theoretical concepts with several illustrative hands-on examples.
If you already went through the first article of the series, then it's quite possible that working with static data in PHP 5 is now a familiar concept to you. In that tutorial, I demonstrated, by way of a few simple (yet functional) examples, how to use a static method to implement the factory pattern. In truth, the definition and further utilization of a static method within a factory class can be considered almost a rule of thumb when it comes to factoring different objects during a the execution of a given PHP application.
The subject, however, goes by far beyond defining a static method as part of a simple factory class. And I'm saying this because admittedly, working with static data in PHP 5 might be incredibly useful in certain cases, a fact that you might not have been aware of until now. Thus, provided that you already have an average background in using static methods with PHP 5, over the course of this second article of the series I'll dive a bit deeper into this interesting topic and show you how to take advantage of static properties defined inside a given PHP class, in this manner completing, at least basically, the implementation of static data with PHP 5.
Even though the term "static" sounds like it refers to a thing that does nothing, in the new few lines you'll be hopefully surprised at the great range of PHP applications that can incorporate the remarkable benefits of using static properties in their classes.
Having introduced the subject of this second installment of the series, it's time to step forward and continue learning with more examples of how to use static properties with PHP 5. It's going to be an educational journey, trust me!