Popular Posts

Friday, 2 July 2010

Object Oriented Programming PHP

Object Oriented Programming PHP

For orignial post kindly visit www.apepoint.com


Object oriented programming is the dominant programming paradigm these days, having replaced the "structured procedure based programming techniques".

In oop the program is made of objects, with certain properties and operations that the object can perform oop reverses the order and puts data first then looks at the algorihms that seperates on the data

once you understand the oop concept I ensure you that the developing a big projects will be an ordinary task for you I must write haere that if you are developing an application that is small and you can develop alone then you can go for procedure programming but if your application is big and in tean no of peoples are plural so you must use this befor moving any example is i recommend you to under stand some more concepts


Classes

A class definition begins with the keyword class followed by whatever name assign to it and variable and methods within braces.

Properties and method

when we define a class we define some of the variable's inside that are accessible in its functions are knowns as properties. These variable maintain the state of object.


In class as variable are define we define function these function are called methods they are aas a method for communicating with and manipulating the data within the object Methods provided the object with a standard interface that any one can use.

Public Private

The visibility of the properties and methods of a class can be set as public or provate. Those that are marked wiht the private keywork are only accessibel from within the class itself . Those marked with the public keywork on the other hand are accessible from both inside and outside of the class.


Constructors and Destructors
In some cases we need to initialize the some of properties of a class we can do it by using constructors they are methods which are written inside class define and the name of this method is same as class name.

In some cases we want to close some resources before moving from that class object we can do so by using destructors.

Example

class MyDestructableClass {

function MyDestructableClass () {
print "In constructor\n";
$this->name = "MyDestructableClass";
}


function __destruct() {
print "Destroying " . $this->name . "\n";
}

}

$obj = new MyDestructableClass();
?>

here in above example method function MyDestructableClass () { } is a constructor and the another method is a Destructors



For more example kindly click on the link script tute from main menu.
In this i explained about the visitors tracking by using php mysql

No comments:

Post a Comment