HomePHP Defining Public and Protected Methods with Member Visibility in PHP 5
Defining Public and Protected Methods with Member Visibility in PHP 5
In the previous articles of this series, I explained how to work with public and protected class properties. So now itís time to demonstrate how to specify these same levels of visibility in the respective methods of a class. Sounds pretty interesting, right?
As an enthusiastic PHP programmer, you should be aware of how useful it can be to protect the data members of your classes from unwanted access. Fortunately, when working specifically with PHP 5, setting different levels of restriction for the methods and properties of a specific class is a process reduced to specifying the appropriate keywords (i.e. whether they're going to be public, protected, or private).
However, if you're just starting to explore the huge terrain of object-based programming in PHP 5, then you're probably looking for a comprehensive guide on how to use the member visibility feature incorporated into this language's object model. In that case, there's good news for you. In this group of articles you'll learn all that you need to begin working with public, protected, and private class members in PHP 5.
Now that you know what will be treated in this fourth chapter of the series, it's time to learn how to declare and implement public and protected methods with PHP 5 classes.
Of course, as always I'm going to address this useful topic by using a hands-on approach, which means that there's a bunch of code samples ahead, waiting patiently for you. So, don't waste more time and start reading this article now!