PHP
  Home arrow PHP arrow Working with Private Properties to Pro...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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? 
PHP

Working with Private Properties to Protect PHP 5 Class Data
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-05-28

    Table of Contents:
  • Working with Private Properties to Protect PHP 5 Class Data
  • A review of public and protected class properties in PHP 5
  • Extending the use of protected class properties: working with a subclass
  • Defining private class properties

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Working with Private Properties to Protect PHP 5 Class Data


    (Page 1 of 4 )

    Welcome to the second installment of the series, “Protecting the data of PHP 5 classes with member visibility.” It is made up of six comprehensive tutorials and provides you with a guide to help you get started using member visibility with PHP 5. It also complements the corresponding theoretical concepts with illustrative hands-on examples.

    One of the most useful features that was introduced into the improved object model of PHP 5 is “member visibility.” It provides PHP developers with the ability to specify the level of access each data member of a class will have in the context of a given application. This helpful characteristic of the language allows the user to declare methods and properties of a certain class that will be available in the global scope via the “public” keyword. It also establishes more restrictive access levels by using the “protected” and “private” reserved words.

    That being said, it’s time to refresh the concepts that were deployed in the last episode of the series, in case you haven’t had the chance to read it yet. Simply put, in that article, I developed a few basic hands-on examples aimed specifically at demonstrating how to declare and work with public and protected properties defined within a primitive data saving class. This came in handy for storing some simple strings in a specified text file.

    In the first case, the properties of the class were declared public, meaning they could be directly accessed from outside the class in question. In the second case, the same properties were defined as protected, implying that they could only be retrieved from inside the originating class and from their eventual subclasses as well.

    So to summarize, I've already covered the use of public and protected class properties in PHP 5. Thus, the next step in this learning process will consist of showing you how to work with private properties. Sounds pretty interesting, right?

    So, let’s not waste more time with preliminaries and see how to use private properties when working with PHP 5 classes. Let’s get going!

    More PHP Articles
    More By Alejandro Gervasio


       · This chapter of the series covers the declaration and use of private class...
     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway