Programming Basics

  Home arrow Programming Basics arrow Object-Oriented PHP
PROGRAMMING BASICS

Object-Oriented PHP
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2010-05-05

    Table of Contents:
  • Object-Oriented PHP
  • The Benefits of OOP
  • Key OOP Concepts
  • Fields

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement

    Object-Oriented PHP


    (Page 1 of 4 )

    If you've never used the object-oriented programming model, PHP 5 comes as a major revelation. This three-part article introduces you to the language's OOP features and explains their advantages. It is excerpted from chapter six of the book Beginning PHP and PostgreSQL 8: From Novice to Professional, written by W. Jason Gilmore and Robert H. Treat (Apress; ISBN: 1590595475).

    This chapter and the next introduce what is surely PHP 5’s shining star: the vast improvements and enhancements to PHP’s object-oriented functionality. If you’ve used PHP prior to version 5, you may be wondering what the buzz is all about. After all, PHP 4 offered object-oriented capabilities, right? Although the answer to this question is technically yes, version 4’s object-oriented functionality was rather hobbled. Although the very basic premises of object-oriented programming (OOP) were offered in version 4, several deficiencies existed, including:

    1. An unorthodox object-referencing methodology
       
    2. No means for setting the scope (public, private, protected, abstract) of fields and methods 
       
    3. No standard convention for naming constructors
       
    4. Absence of object destructors 
       
    5. Lack of an object-cloning feature 
       
    6. Lack of support for interfaces

    In fact, PHP 4’s adherence to the traditional OOP model is so bad that in Jason’s first book, A Programmer’s Introduction to PHP 4.0, he devoted more time to demonstrating hacks than to actually introducing useful OOP features. Thankfully, version 5 eliminates all of the aforementioned hindrances, offering substantial improvements over the original implementation, as well as a bevy of new OOP features. This chapter and the following aim to introduce these new features and enhanced functionality. Before doing so, however, this chapter briefly discusses the advantages of the OOP development model.


    Note  While this and the following chapter serve to provide you with an extensive introduction to PHP’s OOP features, a thorough treatment of their ramifications for the PHP developer is actually worthy of an entire book. Conveniently, Matt Zandstra’s PHP 5 Objects, Patterns, and Practice (Apress, 2004) covers the topic in considerable detail, accompanied by a fascinating introduction to implementing design patterns with PHP and an overview of key development tools such as Phing, PEAR, and phpDocumentor.


    More Programming Basics Articles
    More By Apress Publishing

    blog comments powered by Disqus

    PROGRAMMING BASICS ARTICLES

    - Control Flow Constructs
    - More Time Manipulation with PHP
    - Validating and Manipulating Dates with PHP
    - Using the Date Constructor in PHP
    - Calendar Construction with PHP
    - PHP`s Calendar Package
    - Getting Modified Versions and Correct Dates ...
    - Combining Date Functions in PHP
    - Using PHP for Date and Time in Programming
    - More Exception Handling with PHP
    - Exception Handling in PHP
    - Error Logging and Handling Exceptions
    - Configuration Directives for Error and Excep...
    - Error and Exception Handling
    - Python Modules for Games


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