If you’re an eager PHP developer who wants to have at your disposal a quick guide that shows you how to work with the most relevant magic functions provided by PHP 5, then this series of articles might be what you’re looking for. In this fifth part of a seven-part tutorial on magic functions, we'll briefly review the sleep and wakeup functions, and then tackle the clone function.
Web Development specialist, Luke Dingle presents us with another great tutorial based upon Object Oriented Programming (OOP) and PHP5.
You can create read-only object variables by using the “private” keyword and the __get() and __set() magic methods like this ...
With PHP 5.3 coming up on the horizon, I'm of course looking forward to using namespaces.
How about that catchy title eh? If you are reading this, you must be REALLY dedicated to learning about Object Orientated applications!
This article will try to explain some OO principles to you, as well as some ‘good practice’.
Know what to expect: there will be no funny pictures, no diagrams. There will be some code, but that won’t be very exciting either. This is all pretty dry stuff. Regardless, it is important. This tutorial will include some of the things intentionally left out of part 1, as mentioned in section 1.2 of that tutorial.
Still feel like it? Come on then, time to get your foundations in place!
On the old site, I started a series of tutorials named "PHP Application Design". I planned for at least three parts, and while I did publish the first two and wrote at least half of part three, I found myself out of time to make it to the finish.
Still dedicated to writing reusable and extensible PHP code and spreading the knowledge, this is a restart of the series, renamed as simply "OO PHP". So:
Welcome to part one of the "OO PHP" series.
This article is an overview of what PHP has to offer with respect to OOP, with examples on how to use these concepts.
If you have wanted to grasp OOP, but haven't come around to learning it, this article is for you. If you've read some "Hello World" in OOP tutorial, gotten familiar with OOP syntax but are interested in learning more, this article is for you too.
A couple of things have changed in this tutorial. First off, PHP 4 examples and references have been stripped. PHP 4 is dead, let’s look to the future. In that same frame of mind, this tutorial now has some brief coverage of namespaces and late static binding, introduced in PHP 5.3. Finally, the last chapter from the original has been stripped, or rather moved to a future part of the series.
It’s a good question, for it is true that global variables are often demonised and more recently the Singleton has befallen the same fate. Perhaps a bit surprising, it is remarkably hard to find good arguments to support this common knowledge — Googling turns up a lot of confusion.
As I have often taken this stance myself, I found it reasonable that I should be able to argue for it, so I’ll try to give an explanation. This is also in part a follow-up on my post from last week, in which I present a way to avoid global symbols, without spending much time on why.
Welcome to the final chapter of the series “Understanding Destructors in PHP 5.” In consonance with this article’s title, this series walks you through the basics of utilizing class destructors in object-based applications and also provides you with a decent number of hands-on examples, so you can start incorporating these useful methods into your PHP 5 classes with minor efforts.
Welcome to the fourth part of the series “Understanding Destructors in PHP 5.” Made up of five comprehensive tutorials, this series brings to you the foundations of how to declare and implement destructors in PHP 5-driven classes. And it tackles this process from a practical point of view, since you’ll be able to learn these methods by using copious examples.
As you know, a destructor is simply a magic method supported by the highly-improved object model of PHP 5. When implemented by a determined object, it will be automatically called by the interpreter prior to removing the object in question from the web server’s memory.
Obviously, the intrinsic nature of destructors make them very useful for performing certain tasks, right before a specific application finishes its execution and all of its objects are deleted. Therefore, if you wish to learn how to use them as part of your own PHP 5 classes, this group of educational articles might be the guide that you’ve been searching for.
In the object oriented programming style, it’s preferable to split functionality out to multiple objects, that can work together to solve a single task. Taken to the extreme, this results in more, but smaller, classes and generally relies less on inheritance and more on composition. In lack of better words, I’ll call this compositional programming style. It’s a style which is usually more prevalent with experienced programmers.
For someone coming from an imperative style of programming, this style can appear abstract and confusing, but the benefits are in the flexibility of the code. If different objects are related through composition, parts can be replaced, without changing the code. This makes it easier to reuse components, and to hook into the code, by providing a wrapper here or there. This is especially useful during testing, since it becomes easier to mock out external dependencies (Such as a database or an smtp server).
There is, however, a dark side to composition — dependencies.








