2015-02-09 61 views
0

问题是: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);
输出应该是布局+解析的内容Yii的渲染变量不能查看文件

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

任何帮助,将不胜感激。

回答

0

Yii中有一些渲染函数可以用来达到目的,但不能用于变量。最好使用renderFile()。如果你想将数据传递到该文件中使用

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

More render funtions described here

+0

是啊..但我需要准确变量而不是文件 – 2015-02-09 10:50:35