How to call static block into a phtml file Magento 2

There is a syntax error in your code in near >toHtml

It should be ->toHtml()

<?php echo $this->getLayout()->createBlock(\Magento\Cms\Block\Block::class)->setBlockId('varmo_custom_block_for_header')->toHtml();?>

You can try this:

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

This is another option:

{{block class="Magento\\Cms\\Block\\Block" block_id="block_identifier"}}

Tags:

Magento2