Object Oriented Programming in PHP
Object Oriented Programming Concepts in PHP ,
Basic OOPS Concepts,
: 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.
: 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.
: 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.
: These are the function defined inside a class and are used to access object data.
Basic Program using OOPS classes and objects
public $prop1 = "Class Variable";
public function setProperty($newval)
$this->prop1 = $newval;
public function getProperty()
return $this->prop1 . "<br />";
$obj = new MyClass;
OUTPUT: Class Variable.