RenderDynamic examples. Not found nowhere

Hello. I need to use renderdynamic in Yii2 but there is no examples of use. Specially I need examples of use by trying to call a method on the controller in order to render "freshly" the content on that controller.

In Yii1:


controller:

public function renderTracking($params = [])

{

   return date("Ymd His");

}


view:

$this->renderDynamic('renderTracking', $params)

How It will be in Yii2?

I want to refer about this issue:


<?= $this->renderDynamic('return foo($var);', [

    'var' => $var,

]) ?>

Where is supposed is located foo()?

If I locate "foo()" in the same view, It throw the error: "Call to undefined function foo()"





<?php function foo($var){return "XX";} ?>


<?= $this->renderDynamic('return foo($var);', [

    'var' => $var,

]) ?>




So, where is supposed must to be foo()? Before in the view? In the controller? Where?