What are the potential pitfalls of using global variables in PHP, especially in object-oriented programming?

Using global variables in PHP, especially in object-oriented programming, can lead to several issues such as tight coupling, reduced reusability, and difficulty in debugging. To avoid these pitfalls, it's better to pass variables as parameters to functions or methods, or use class properties to store and access data within the scope of the class.

class MyClass {
    private $myVariable;

    public function setVariable($value) {
        $this->myVariable = $value;
    }

    public function getVariable() {
        return $this->myVariable;
    }
}

$myObject = new MyClass();
$myObject->setVariable("Hello World");
echo $myObject->getVariable(); // Output: Hello World