PHP
  Home arrow PHP arrow More on Private Methods with PHP 5 Member Visibility
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

More on Private Methods with PHP 5 Member Visibility
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2008-06-25


    Table of Contents:
  • More on Private Methods with PHP 5 Member Visibility
  • Reintroducing a previous hands-on example
  • Calling a private method from a subclass
  • Another way to protect class methods: the final keyword

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    More on Private Methods with PHP 5 Member Visibility
    ( Page 1 of 4 )

    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!



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

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek