In what ways can understanding object-oriented programming principles improve the efficiency and readability of PHP code, especially when working with frameworks like Smarty?

Understanding object-oriented programming principles can improve the efficiency and readability of PHP code by promoting code reusability, encapsulation, and modularity. When working with frameworks like Smarty, using OOP can help organize code into logical classes and objects, making it easier to maintain and extend the application.

class User {
    private $username;
    private $email;
    
    public function __construct($username, $email) {
        $this->username = $username;
        $this->email = $email;
    }
    
    public function getUsername() {
        return $this->username;
    }
    
    public function getEmail() {
        return $this->email;
    }
}

$user = new User('JohnDoe', 'johndoe@example.com');
$smarty->assign('user', $user);
$smarty->display('profile.tpl');