How can the use of "$this" keyword in PHP classes impact variable access and scope?

When using the "$this" keyword in PHP classes, it allows you to access class properties and methods within the class itself. This keyword is used to differentiate between local variables and class properties with the same name, ensuring the correct scope is accessed. By using "$this", you can avoid conflicts and ensure the intended variables are accessed within the class.

class Example {
    private $name;

    public function setName($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

$example = new Example();
$example->setName("John Doe");
echo $example->getName(); // Output: John Doe