Home arrow PHP arrow Utilizing Private Methods with PHP 5 and Member Visibility

Utilizing Private Methods with PHP 5 and Member Visibility

Welcome to the fifth chapter of the series, “Protecting the data of PHP 5 classes with member visibility.” Comprised of six parts, this series teaches you how to define the levels of visibility that properties and methods of a specific class will have when developing PHP5-controlled applications. This article will show you how to declare methods and properties private.

TABLE OF CONTENTS:
  1. Utilizing Private Methods with PHP 5 and Member Visibility
  2. Working with protected methods in PHP 5-controlled environments
  3. Working with private data members
  4. Accessing private methods with a public one
By: Alejandro Gervasio
Rating: starstarstarstarstar / 5
June 18, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The improved object model incorporated by PHP 5 provides programmers with the capacity to set up three different levels of access to the data members of classes. This implies that it's very easy to specify whether the properties and methods of a given class will be public, protected, or private.

However, if you're looking for an approachable guide that walks you through the basic concepts that surround the implementation of member visibility in PHP 5, then look no further because you've come to the right place.

Of course, when it comes to specifying how visible a certain class property or method will be, you know that PHP 5 permits you to work with three distinct levels of access, called "public," "protected," and "private" respectively. The preceding articles of the series were focused specifically on explaining how to assign the first two grades of visibility to the properties and methods of a rudimentary data saving class.

Hopefully, after playing around with the code samples included in the aforementioned tutorials, you're adequately armed with the required background to start using public and protected data members within your own PHP 5 classes. As you may have noticed, however, I've not taught you how to define private methods yet, which is something that can definitely be very useful if you want to restrict the access to your classes from the outside more severely.

Therefore, in this fifth episode of this series, I'll be explaining how to declare and implement private methods inside of a sample PHP class. This way you can begin incorporating this feature into your own object-oriented applications.

Now, let's continue this educational journey about using member visibility with PHP 5. Let's go!



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