How to Create instance object for magento2 block

How to Create instance object for magento2 block:

This is script is as same as magento1.x. Some times we may want to create 

instance object for Magento2 block file. Using instance object we can use 

the block file method & functions.

$blockObj= $block->getLayout()->

createBlock('Mypackage\mymodule\Block\MyBlock');

 echo $blockObj->getMyBlockMethod();

CORNER OF BLOG:

“Be attached to the One, who is attached to none.
Be so attached to be free of any attachments.

– ” Thirukkural

Leave a Reply