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

TABLE OF CONTENTS:
  1. More on Private Methods with PHP 5 Member Visibility
  2. Reintroducing a previous hands-on example
  3. Calling a private method from a subclass
  4. Another way to protect class methods: the final keyword
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
June 25, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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!



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