What are the limitations of using variables directly within a class declaration in PHP, as seen in the provided code snippet?

Using variables directly within a class declaration in PHP can lead to syntax errors or unexpected behavior. To solve this issue, we can initialize the variables within the constructor method of the class instead of directly within the class declaration.

class MyClass {
    private $variable;

    public function __construct($value) {
        $this->variable = $value;
    }

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

$obj = new MyClass('Hello');
echo $obj->getVariable(); // Output: Hello