What are some common pitfalls when working with PHP classes?

One common pitfall when working with PHP classes is not properly initializing class properties, leading to unexpected behavior or errors. To solve this, make sure to initialize all class properties either in the class definition or in the constructor method.

class MyClass {
    private $property;

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