PHP
  Home arrow PHP arrow Object Oriented Programming in PHP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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

Object Oriented Programming in PHP
By: Luis Argerich
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 258
    2003-01-13

    Table of Contents:
  • Object Oriented Programming in PHP
  • Data Members and Functions
  • Constructors
  • Overloading
  • OOP Programming in PHP
  • Copying and Cloning
  • Conclusion

  • 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


    Object Oriented Programming in PHP


    (Page 1 of 7 )

    This article introduces Object Oriented Programming (OOP) in PHP. Luis shows you how to code less and better by using some OOP concepts and PHP tricks.Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For example you may have a Person object to hold the data related to a person and even provide some functionality that this person may be capable of.

    Object Oriented Programming has long been used in games to represent the objects such as a User or an Enemy, or even a Weapon. This amazing way of programming has proven just as useful in software and web development.

    In my opinion any OOP language should have:
    • Abstract data types and information hiding
    • Inheritance
    • Polymorphism
    This can all be done using PHP classes:

    <?php

    class Something {
    // In OOP classes are usually named starting with a cap letter.
    var $x;

    function setX($v) {
    // Methods start in lowercase then use lowercase to separate
    // words in the method name example getValueOfArea()
    $this->x=$v;
    }

    function getX() {
    return $this->x;
    }
    }

    ?>


    Of course you can use your own nomenclature but having a standardized one is useful.

    More PHP Articles
    More By Luis Argerich


       · Thanks for the article.Just wanted to correct a typo..to make the internet a...
       · This article is pretty old, it needs updation for PHP version 5 and later.
       · This OOPs is very helpful me, but i expects with author to make it update plz for...
       · :rofl:PHP is not an OOP language in the first place. It's meant to be simple and...
       · Obviously the good people from PHP.net thought it was the right way to go seeing as...
       · another nice way of using persistent objects can be found here...
       · what great news that php-people included some persistent object stuff. I never...
       · :yes: plz update with explained examples
     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP







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