Monday, July 21, 2008

PHP With Object Oriented Programming : Some Facts

Learn Object Oriented Programming (OOP) in PHP

Object-Oriented Programming (OOP) is a type of programming added to php5 that makes building complex, modular and reusable web applications that much easier.
With the release of php5, php programmers finally had the power to code with the 'big boys'. Like Java and C#, php finally has a complete OOP infrastructure.

OOP is all about creating modular code, so our object oriented PHP code will be contained in dedicated files that we will then insert into our normal PHP page using php 'includes'.
OOP revolves around a construct called a 'class'. Classes are the cookie-cutters / templates that are used to define objects.

Instead of having a bunch of functions, variables and code floating around willy-nilly, to design your php scripts or code libraries the OOP way, you'll need to define/create your own classes.
You define your own class by starting with the keyword 'class' followed by the name you want to give your new class.

Classes are the blueprints for php objects - more on that later. One of the big differences between functions and classes is that a class contains both data (variables) and functions that form a package called an: 'object'. When you create a variable inside a class, it is called a 'property'.

Why learn OOP in PHP

For people new to OOP and are comfortable with 'classic' procedural php, you may be wondering why should you even bother to learn object oriented concepts … why go through the trouble?

The PHP world:

PHP is moving in an OOP direction. For example, many important PHP extensions like PEAR and Smarty are OO based. So, to really understand and use these frameworks properly, you need to understand object oriented PHP.

The functional/practical advantages:

For smaller projects, using object oriented PHP may be overkill. That said, object oriented PHP really begins to shine as the project becomes more complex, and when you have more than one person doing the programming.

Example:
If you find that you have say 10-20 or more functions and you find that some of the functions are doing similar things … it is time to consider packaging things up into objects and using OOP.

For More About the above contents, Download Basics PHP OOP In Pdf....Enjoy!!!

No comments: