What potential pitfalls should be considered when using global variables in PHP classes?

Using global variables in PHP classes can lead to issues with code maintainability, readability, and reusability. It can make it difficult to track where and how the global variable is being used within the class, which can lead to bugs and unexpected behavior. Instead, consider using class properties to encapsulate data within the class and pass any necessary values through the class constructor or method parameters.

class MyClass {
    private $myProperty;

    public function __construct($myValue) {
        $this->myProperty = $myValue;
    }

    public function myMethod() {
        // Use $this->myProperty here
    }
}

$myInstance = new MyClass('my value');
$myInstance->myMethod();