I have block Class Name NameSpace1\Test\Block\Test
with method getTest()
namespace NameSpace1\Test\Block;
class Test extends \Magento\Framework\View\Element\Template {
public function getTest(){
return "Same Result";
}
}
My Template file name test.phtml with following code
<h3>Class: <?php echo get_class($block) ?> Result: (<?php echo $block->getTest() ?>)</h3>
<h3>Class: <?php echo get_class($this) ?> Result: (<?php echo $this->getTest() ?>)</h3>
and output the code is following result
my question is what is difference between $this and $block and which is better to use in my template file both have get same result