PHP Data Types Objects

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP Data Types : Objects


An object is a data type which stores not only data but also information on how to process that data. Unlike the other data types in PHP, an object must be explicitly declared.

At first, we must declare a class of object. A class is a structure which contains properties and methods.

Classes are defined with the class keyword. We define the data type in the object class, and then we use the data type in instances of that class.


view plaincopy to clipboardprint?

  1. {  

  2. function marks_calculation()  

  3. {           

  4. echo "Display marks";  

  5. }  

  6. }  

  7. $student1 = new student;  

  8. $student1->marks_calculation();   

  9. ?>