Home arrow PHP arrow Handling Static Data with PHP 5

Handling Static Data with PHP 5

It's pretty common when using PHP to develop dynamic, object-oriented applications. Every so often, though, you need to work with static data. This article will explain how to work with static data and static properties, and show you how this ability can be useful in real-world situations.

TABLE OF CONTENTS:
  1. Handling Static Data with PHP 5
  2. Building dynamic web page DIVs
  3. Factoring DIVs using both conventional and dynamic methods
  4. Putting all the classes together
By: Alejandro Gervasio
Rating: starstarstarstarstar / 7
September 11, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

When you start learning some of the most important concepts for using the object-oriented paradigm with PHP, you quickly realize the remarkable benefits of building classes and objects, defining their methods and properties, and working with aggregation and composition as well.

Of course, things get interesting when you begin applying the pillars of object-based programming, such as inheritance and polymorphism. At that point you've already acquired a decent background in developing dynamic, object-oriented PHP applications. I purposely used the term "dynamic" because it implies the existence of one or more classes that perform different tasks and output "dynamic" results.

However, while defining a bunch of dynamic methods for a given class certainly is one of the most common process that a PHP developer has to tackle on a frequent basis, the truth is that the powerful object model offered by PHP 5 allows you to work with static data too, in a very approachable fashion. But, in the context of PHP programming…what does static data mean?

Well, in simple terms, when a method of a class is declared static, it can be called from outside the object context, just like a conventional PHP function, thus avoiding the direct instantiation of that particular class. Pretty useful, right?

Besides, there's more good news on the horizon, since PHP 5 does let you work with static properties, which means that when a class property is declared static, then it will be unique for the entire class, in this way being callable from outside the object context, and also shared by all the instances of that specific class.

Perhaps, if you reread the above sentences, you may find the concept of working with static data in PHP 5 rather hard to grasp, or even pointless, but the truth is that in real world situations, this feature can be extremely useful. Therefore, and assuming that the subject of this series has already caught your attention, in this group of tutorials I'll be taking a close look at creating and using static properties and methods with PHP 5, and also provide you with numerous hands-on examples so you can acquire a solid grounding in this important topic.

Are you ready to learn how to declare and use static data with PHP 5? Then don't you stay static; begin reading now!



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

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