How can object-oriented programming principles be applied to PHP to improve code structure?

Object-oriented programming principles can be applied to PHP by creating classes that represent entities or objects in your code. This helps to improve code structure by organizing related functions and data into cohesive units. By using classes, you can encapsulate data and behavior, promote code reusability, and improve maintainability.

// Example of applying object-oriented programming principles in PHP

class Car {
    private $make;
    private $model;
    
    public function __construct($make, $model) {
        $this->make = $make;
        $this->model = $model;
    }
    
    public function getMake() {
        return $this->make;
    }
    
    public function getModel() {
        return $this->model;
    }
}

$car = new Car('Toyota', 'Corolla');
echo $car->getMake(); // Output: Toyota
echo $car->getModel(); // Output: Corolla