What are the differences in object-oriented programming features between PHP4 and PHP5, and how can developers adapt their code accordingly?

In PHP5, new object-oriented programming features were introduced, such as visibility keywords (public, protected, private), abstract classes, interfaces, and magic methods. Developers can adapt their code by updating their classes to use these new features and ensuring compatibility with PHP5.

// PHP4 code
class MyClass {
    var $property;

    function MyClass() {
        $this->property = 'value';
    }

    function getProperty() {
        return $this->property;
    }
}

// PHP5 code
class MyClass {
    private $property;

    public function __construct() {
        $this->property = 'value';
    }

    public function getProperty() {
        return $this->property;
    }
}