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

TABLE OF CONTENTS:
  1. Defining Public and Protected Methods with Member Visibility in PHP 5
  2. Calling methods of a class globally
  3. Declaring and implementing protected methods within PHP 5 classes
  4. Calling protected methods from a subclass
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
June 11, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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!



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

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: