What are the differences between defining object properties using "var" in PHP4 versus using "public, protected, or private" in PHP5?

In PHP4, defining object properties using "var" made them public by default. In PHP5, the use of "var" to define properties has been deprecated in favor of explicitly declaring the visibility of properties using "public", "protected", or "private". This change allows for better encapsulation and control over access to object properties.

// PHP4 style of defining object properties
class MyClass {
    var $publicProperty;
}

// PHP5 style of defining object properties
class MyClass {
    public $publicProperty;
    protected $protectedProperty;
    private $privateProperty;
}