What are the potential pitfalls of using public properties in PHP classes?

Using public properties in PHP classes can lead to a lack of encapsulation and can make it difficult to control access to the data within the class. This can result in unintended changes to the data and potential conflicts with other parts of the code. To solve this issue, it is recommended to use private or protected properties along with getter and setter methods to control access to the data.

class MyClass {
    private $myProperty;

    public function getMyProperty() {
        return $this->myProperty;
    }

    public function setMyProperty($value) {
        $this->myProperty = $value;
    }
}