Where\'s the difference between self and $this-> in a PHP class or PHP method?
Example:
I\'ve seen this code recently.
$this-> when dealing with extended class will refer to the current scope that u extended , self will always refer to the parent class because its doesn't need instance to access class method or attr its access the class directly.
classCheck();
self::classCheck();
}
function classCheck(){
echo "First Class";
}
}
class SecondClass extends FirstClass{
function classCheck(){
echo "Second Class";
}
}
$var = new SecondClass();
$var->selfTest(); //this-> will refer to Second Class , where self refer to the parent class