How can instance variables be accessed within a method in PHP?
Instance variables in PHP can be accessed within a method using the `$this` keyword followed by the arrow operator `->`. This allows the method to refer to the specific instance of the class and access its variables. By using `$this->variableName`, you can read or modify the instance variable within the method.
class MyClass {
public $instanceVar = "Hello";
public function printVar() {
echo $this->instanceVar;
}
}
$obj = new MyClass();
$obj->printVar(); // Output: Hello