Magento – How to instantiate the helper class in the phtml in Magento2

magento2

In my Module, i just have a Block.

I am not using any Controller in my custom module.

In my phtml template i need to call helper class like below, We used to call in Magento1.

  $params =$this->getRequest()->getParams();  
  $helper = Mage::helper("My Helper class");  //Here how to instantiate the helper in my phtml
  $filters = $helper->getmydata();
  $res = $helper->getSearchData();

How can i use helper in phtml in Magento2.

Best Answer

We can call helper class in template file like

$_helper = $this->helper('Magento\Catalog\Helper\Output');

use $_helper object to call helper method.