How can variables be accessed from classes in PHP?

In PHP, variables can be accessed from classes using class properties. These properties can be defined within the class using the `$this` keyword. By setting the visibility of the properties (public, private, or protected), you can control how they can be accessed from outside the class. To access the variables from outside the class, you can create an instance of the class and then use the arrow operator (`->`) to access the properties.

class MyClass {
    public $myVariable = 'Hello World';

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

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