Yii渲染变量不查看文件


Yii render variable not view file

问题是:Does Yii have any method(s) to render variable with code in it?

默认值:
$this->render('site/index');,其中site/index是查看文件的路径

我需要做的是:
$content = '<div><?php echo "do something here"; ?></div>';
$this->render($content);
输出应为布局+解析内容

我尝试使用$this->renderText($content);,但这些方法返回空字符串
我使用Smarty扩展来渲染视图文件,然后$this->renderText($content);返回未解析的字符串:{assign ..}

如有任何帮助,我们将不胜感激。

Yii中有一些渲染函数可以用来实现,但不能使用变量。最好使用renderFile()。如果您想将数据传递到此文件,请使用

$this->renderFile("renderfile.php",array("var1"=>"xyz","var2"=>"abc");

此处描述的更多渲染功能