To reference the current class instance the keyword $this can be used. Through the use of this keyword you have access to class properties and methods.
Static methods can be accessed without instantiating the class, so $this is not available for them. Using $this in a
static context will result in a runtime error.
class Clazz {
public $name = NULL; // instance variable
public static function foo() {
if ($this->name != NULL) {
// ...
}
}
}
class Clazz {
public $name = NULL; // instance variable
public static function foo($nameParam) {
if ($nameParam != NULL) {
// ...
}
}
}