How can I access a class variable within a method in PHP?

To access a class variable within a method in PHP, you can use the `$this` keyword followed by the variable name. This allows you to reference the class variable from within the method. Make sure the variable is defined within the class scope for it to be accessible within the methods.

class MyClass {
    public $myVariable = 'Hello';

    public function printVariable() {
        echo $this->myVariable;
    }
}

$obj = new MyClass();
$obj->printVariable(); // Output: Hello