What potential pitfalls should developers be aware of when using classes and objects in PHP, especially when it comes to method functionality?

One potential pitfall developers should be aware of when using classes and objects in PHP is the issue of method visibility. It is important to properly set the visibility of methods to ensure they can be accessed and used correctly within the class and by external code. By default, methods are public, but developers can also use private and protected visibility to control access to methods.

class MyClass {
    private function myPrivateMethod() {
        // do something
    }

    public function myPublicMethod() {
        // call private method from within the class
        $this->myPrivateMethod();
    }
}

$obj = new MyClass();
$obj->myPublicMethod(); // this will work
$obj->myPrivateMethod(); // this will cause a fatal error