HomePHP More on Private Methods with PHP 5 Member Visibility
More on Private Methods with PHP 5 Member Visibility
Welcome to the final chapter of the series, “Protecting the data of PHP 5 classes with member visibility.” Complemented by copious illustrative examples, this article series guides you through learning the key concepts regarding the use of public, protected, and private data members within PHP 5 classes. This way you can start defining the visibility of the properties and methods of your own classes in a very short time.
Frankly speaking, one of the most useful features introduced into the object model of PHP 5 is “member visibility.” This comes in handy for specifying whether the data members of a certain class will be public, protected. or private.
At a glance, determining the visibility of methods and properties of a given class may seem like a pretty straightforward process that can be tackled with minor hassles. However, when building object-oriented applications that work in real-world conditions, this procedure can be challenging.
Thus, if you’re a PHP developer who wants to learn in an easy way to work with public, protected, and private class members when using PHP 5, then you should start reading this article now!
Now that you've been introduced to the main subject of this series, it’s an excellent time to recapitulate the group of topics that I discussed in the last article. As you’ll probably recall, I explained how to declare and implement private methods within a basic PHP 5 class.
Of course, all of the examples were pretty simplistic and certainly wouldn’t be used directly in real world conditions. However, they did show how easy it is to define private methods in PHP 5, and also how useful they can be in certain situations, particularly those cases where it’s necessary to severely protect the member of a given class from undesired access.
Assuming that you’re familiar with working with private methods in PHP 5, it’s time to leap forward and tackle this final article of the series, which will be focused on covering some additional aspects concerning the use of this kind of class method. In addition, I’ll teach you how to utilize the “final” keyword, which is included with PHP 5, to prevent the methods of a specific class from being overridden by any subclass.
Are you ready to begin reading this last episode? Let’s get started!