Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

16. OOP Fundamentals

Lesson 13 of 29 in the free PHP Programming notes on Siksha Sarovar, written by Rohit Jangra.

Object-Oriented Programming (OOP) in PHP

Object-Oriented Programming (OOP) is a programming approach that organizes code using classes and objects, making programs modular, reusable, secure, and easy to maintain.

Exam Definition: OOP is a programming paradigm based on the concept of objects which contain data and methods.

---

Classes, Objects, Fields, Properties, Methods

Class

A class is a blueprint or template used to create objects.

class Student {
   public $name;
   public function show() {
      echo "Student Class";
   }
}

Object

An object is an instance of a class.

$s1 = new Student();
$s1->show();

Fields / Properties

Variables declared inside a class are called properties (or fields).

public $name;
private $age;

Methods

Functions declared inside a class are called methods.

public function display() {
   echo $this->name;
}
Exam Line: Properties store data and methods define behavior.