Object-Oriented Programming (OOP) is a programming paradigm that uses objects and classes to represent real-world entities. It focuses on encapsulation, inheritance, and polymorphism to organize code and improve reusability.

PHP has built-in support for OOP from version 5, and it continues to evolve with each new release. In this guide, we will cover the basic concepts and syntax of OOP in PHP.

1. Class and Object:
A class is a blueprint for creating objects. It defines the properties (attributes) and behaviors (methods) of an object. An object is an instance of a class.

“`php
class Person {
public $name;
public $age;

public function greet() {
echo “Hello, my name is ” . $this->name;
}
}

$person = new Person();
$person->name = “John”;
$person->age = 30;

$person->greet(); // Output: Hello, my name is John
“`

2. Constructor and Destructor:
A constructor is a special method that is called automatically when an object is created. It is used to initialize the object’s properties. A destructor is a special method that is called automatically when an object is destroyed. It is used to perform cleanup operations.

“`php
class Person {
public $name;

public function __construct($name) {
$this->name = $name;
echo “Object created.”;
}

public function __destruct() {
echo “Object destroyed.”;
}
}

$person = new Person(“John”); // Output: Object created.
“`

3. Encapsulation:
Encapsulation is the process of hiding internal details of an object and providing public methods to access and modify its internal state. It helps in achieving data abstraction and information hiding.

“`php
class Person {
private $name;

public function getName() {
return $this->name;
}

public function setName($name) {
$this->name = $name;
}
}

$person = new Person();
$person->setName(“John”);
echo $person->getName(); // Output: John
“`

4. Inheritance:
Inheritance is the process of creating a new class (derived class) from an existing class (base class). The derived class inherits all the properties and methods of the base class and can add its own properties and methods.

“`php
class Animal {
public function eat() {
echo “Eating…”;
}
}

class Cat extends Animal {
public function meow() {
echo “Meow!”;
}
}

$cat = new Cat();
$cat->eat(); // Output: Eating…
$cat->meow(); // Output: Meow!
“`

5. Polymorphism:
Polymorphism is the concept of using a single interface to represent multiple different types. It allows objects of different classes to be treated as objects of a common base class.

“`php
abstract class Animal {
abstract public function makeSound();
}

class Cat extends Animal {
public function makeSound() {
echo “Meow!”;
}
}

class Dog extends Animal {
public function makeSound() {
echo “Woof!”;
}
}

function animalSound(Animal $animal) {
$animal->makeSound();
}

$cat = new Cat();
$dog = new Dog();

animalSound($cat); // Output: Meow!
animalSound($dog); // Output: Woof!
“`

This is just a basic introduction to OOP in PHP. There are many more advanced topics and techniques in OOP, such as interfaces, abstract classes, namespaces, traits, etc.