How $this variable work inside the template file in Magento?

In Magento, the template file for each block is ‘included’ by a php include directive during the render phase, so it´s clear that $this inside a template file, always refer to the block class instance.

The include is done in the fetchView() method of Mage_Core_Block_Template.