PHP
  Home arrow PHP arrow Utilizing Private Methods with PHP 5 and 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

Utilizing Private Methods with PHP 5 and Member Visibility
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2008-06-18


    Table of Contents:
  • Utilizing Private Methods with PHP 5 and Member Visibility
  • Working with protected methods in PHP 5-controlled environments
  • Working with private data members
  • Accessing private methods with a public one

  • 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


    Utilizing Private Methods with PHP 5 and Member Visibility
    ( Page 1 of 4 )

    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.

    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
     

       

    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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek