Object Oriented Programming
Object Oriented Programming :
An application can be designed using different programming structures like .
1. Procedure oriented programming (pop).
2. Object oriented programming (oop).
3. Aspect oriented programming .
in a procedure oriented programming the two entities of an application there is data and function are treated separately . so , the complexity to develop an application is more.
And a global data can be accessed by any one from any where in the program. To overcome the limitations of procedure oriented programming , oops is introduced . in oops the two entities of an application there is data and functions are treated as a single entity, so the complexity to develop an application is less.
Oops is mainly based on class and objects as per object oriented analysis and design so many definitions are given for a class.
In that the two well known definitions are .
1. Class is a concept.
2. Class is a blue print.
A concept contains items and functionalities each item of a concept is used by performing the particular function.
In a programming language a class is user defined datatype that contains attributes are datamembers and methods . which work on data members.
Every class definition begins with the keyword class followed by a class name.
The member datas of a class should be explicitly access specifier.
Access specifiers a re used to specify from where we can invoke the member data method etc.
The fundamental access specifiers used in php are ,
1. private : private access specifier members can be accessed only with in the context where it is declared.
2. Protected : protected access specified members can be invoked from within context and also by the subclass.
3. Public : public access specified members can be invoked from any where.
The default access specifier of php is PUBLIC.
a pseudo variable , $this is available inside the member function of a class when it is called from within an object context. $this is a reference to the calling object inside the class member function.
An object is a living instance or a real instance of a class .this means that an object is created from the definition of the class and is loaded in memory[heap memory].
Each object has its own memory space that can hold independent data values.
To create an object of a php class were the keyword “new”.
Obj_ref= new classname();
An object can invoke its members by using deferencing operator or arrow operator(->).
$emp =new empref();