What are the common pitfalls for beginners when writing PHP classes?

One common pitfall for beginners when writing PHP classes is not properly understanding the concept of visibility (public, private, protected) for class properties and methods. It is essential to carefully consider which properties and methods should be accessible from outside the class and which should be kept private to ensure encapsulation and maintainability.

class Example {
    private $privateProperty;
    public function __construct($value) {
        $this->privateProperty = $value;
    }
    
    public function getPrivateProperty() {
        return $this->privateProperty;
    }
}