Object Oriented Programming in PHP

by satheeshkumar 2013-06-26 16:42:24

Object Oriented Programming Concepts in PHP ,

Basic OOPS Concepts,

Class: This is a programmer-defined datatype, which includes local functions as well as local data. You can think of a class as a template for making many instances of the same kind (or class) of object.

Object: An individual instance of the data structure defined by a class. You define a class once and then make many objects that belong to it. Objects are also known as instance.

Member Variable: These are the variables defined inside a class. This data will be invisible to the outside of the class and can be accessed via member functions. These variables are called attribute of the object once an object is created.

Member function: These are the function defined inside a class and are used to access object data.

Basic Program using OOPS classes and objects

class MyClass
public $prop1 = "Class Variable";
public function setProperty($newval)
$this->prop1 = $newval;

public function getProperty()
return $this->prop1 . "<br />";

$obj = new MyClass;

echo $obj->prop1;


OUTPUT: Class Variable.


You must LOGIN to add comments