#native_company# #native_desc#
#native_cta#

Object Oriented Programming in PHP: The Way to Large PHP Projects

By Luis Argerich
on January 25, 2008

This arcticle introduces Object Oriented Programming (OOP) in PHP. I will show
you how to code less and better by using
some OOP concepts and PHP tricks. Good luck!
Concepts of object oriented programming:
There’re differences between authors, I can mention that a OOP language must have:
  • Abstract data types and information hidding
  • Inheritance
  • Polymorphism
The encapsulation is done in php using 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 seprate

        // 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 standarized one is useful.

1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9