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

Object-oriented principles can be applied in PHP by organizing code into classes and objects, which helps improve code structure and readability. By encapsulating data and behavior within classes, it makes the code more modular and easier to maintain. Additionally, inheritance and polymorphism can be used to promote code reuse and reduce redundancy.

class User {
    private $name;
    private $email;

    public function __construct($name, $email) {
        $this->name = $name;
        $this->email = $email;
    }

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

    public function getEmail() {
        return $this->email;
    }
}

$user = new User("John Doe", "john.doe@example.com");
echo $user->getName();
echo $user->getEmail();