title: How to call block functions in phtml file in magento 2?
body: <p>I am creating custom module in magento 2. I want to call block functions in phtml file. But It is not working. Please help me.</p>
  
  <p>Here is my block in adminhtml folder file.</p>
  
  <pre><code>namespace Question\Topic\Block\Adminhtml;
  
  class Topic extends  \Magento\Framework\View\Element\Template {
  
  
      public function getSample() {
  
               return "abhishek";
  
      }
  
  }
  </code></pre>
  
  <p>And my topic_order_view.xml file in view/adminhtml/layout is</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"&gt;
      &lt;body&gt;
          &lt;referenceContainer name="content"&gt;
              &lt;block class="Magento\Framework\View\Element\Template" name="view" template="Questions_Topic::view.phtml" /&gt;
          &lt;/referenceContainer&gt;
      &lt;/body&gt;
  &lt;/page&gt;
  </code></pre>
  
  <p>Here is my controller in Controller/Adminhtml/Order/view.php---</p>
  
  <pre><code>namespace Question\Topic\Controller\Adminhtml\Order;
  
  use Magento\Backend\App\Action;
  use Magento\Backend\App\Action\Context;
  use Magento\Framework\View\Result\PageFactory;
  use Magento\Framework\App\Config\ScopeConfigInterface;
  
  class View extends \Magento\Backend\App\Action
  {
  
      /**
       * @var PageFactory
       */
       protected $resultPageFactory;
      /**
       * @var scopeConfig
       * Needed to retrieve config values
       */
      protected $scopeConfig;
  
  
  
     public function __construct(
          Context $context,
          PageFactory $resultPageFactory,
          ScopeConfigInterface $scopeConfig // Needed to retrieve config values
      ) {
          parent::__construct($context);
          $this-&gt;resultPageFactory = $resultPageFactory;
          $this-&gt;scopeConfig = $scopeConfig; // Needed to retrieve config values
      }
  
        public function execute()
      {
          $resultPage = $this-&gt;resultPageFactory-&gt;create();
  
          $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;prepend(__('Orders')); // 
  
           return $resultPage;
  
      }
  }
  </code></pre>
  
  <p>my view.phtml file in view/adminhtml/templates/order/view.phtml</p>
  
  <pre><code>&lt;?php
  //echo $this-&gt;getSample();
  echo $block-&gt;getSample();
  
  ?&gt;
  
  &lt;h1&gt;Hello &lt;/h1&gt;
  </code></pre>
  
  <p>It is showing the <strong>Hello</strong> word. But not echo the above block code  </p>
  
  <p>Thanks in advance..</p>