Magento 2 – Call Different Module Block Function in Custom PHTML

blocksmagento2phtml

I have custom module in which there is custom block and it's associated phtml which call my custom block functions using $block object.

I want to call other module block function in my custom module phtml

So I need to figure out the best way of doing it? I already have the idea how to call other block function in phtml through Objectmanager but it is not the best practice

Any help, knowledge and experience sharing would be appreciated

Best Answer

You Can Call Another Module Block Like This :-

$block = $this->getLayout()->createBlock('\Vendor\Module\Block\FileName')->yourFunction();