Since you checked this magento , you probably have a class like Mage_Catalog_Block_Navigation . At least methods hint at this. Now I have no information about Magento, but this class extends from Mage_Core_Block_Template , and in this class you have a fetchView method that at some point does
include $includeFilePath;
When you include inside a method, you have access to $this in the included code of the file, because it is evaluated within this instance:
When a file is included, the code that it contains inherits the scope of the line in which the inclusion occurs. Any variables available on this line in the calling file will be available in the called file from this point forward. However, all functions and classes defined in the included file have a global scope.
General example:
class Template … public function render($templateFile) { include $templateFile; } public function ___($stringToTranslate) { // translates $stringToTranslate somehow } }
Note that " $this not a self class" is only partially correct. self also a keyword and php, but while self does refer to the class, $this refers to an instance of the class.
source share