How does object-oriented programming in PHP differ from structured programming, and what advantages does it offer?

Object-oriented programming in PHP differs from structured programming by allowing for the creation of classes and objects, which encapsulate data and behavior. This approach promotes code reusability, modularity, and easier maintenance. By using classes and objects, developers can organize code more efficiently and create more complex and scalable applications.

// Example of creating a class and object in PHP

class Car {
    public $make;
    public $model;
    
    public function __construct($make, $model) {
        $this->make = $make;
        $this->model = $model;
    }
    
    public function displayInfo() {
        echo "Car make: " . $this->make . ", Model: " . $this->model;
    }
}

$myCar = new Car("Toyota", "Camry");
$myCar->displayInfo();