【问题标题】:Yii render variable not view fileYii 渲染变量不查看文件
【发布时间】:2015-04-08 22:49:51
【问题描述】:

问题是: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 ..}

任何帮助将不胜感激。

【问题讨论】:

    标签: php yii renderpartial


    【解决方案1】:

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

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

    More render funtions described here

    【讨论】:

    • 是的.. 但我需要的正是变量而不是文件
    猜你喜欢
    • 1970-01-01
    • 2019-03-04
    • 1970-01-01
    • 1970-01-01
    • 2014-04-10
    • 1970-01-01
    • 1970-01-01
    • 2015-09-15
    • 1970-01-01
    相关资源
    最近更新 更多