Home arrow PHP arrow 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.

  1. Understanding Static Properties with PHP 5
  2. Reintroducing a previous hands-on example
  3. Defining static properties within PHP 5 classes
  4. Demonstrating the functionality of a static property
By: Alejandro Gervasio
Rating: starstarstarstarstar / 12
September 12, 2007

print this article




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!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: