How can PHP developers optimize their code for better performance and readability while maintaining a balance between OOP principles and practicality?

To optimize PHP code for better performance and readability while maintaining a balance between OOP principles and practicality, developers can follow best practices such as using proper naming conventions, organizing code into classes and methods, minimizing the use of global variables, and utilizing design patterns where applicable.

class User {
    private $firstName;
    private $lastName;

    public function __construct($firstName, $lastName) {
        $this->firstName = $firstName;
        $this->lastName = $lastName;
    }

    public function getFullName() {
        return $this->firstName . ' ' . $this->lastName;
    }
}

$user = new User('John', 'Doe');
echo $user->getFullName();