gpt4 book ai didi

php - 从部分面包屑访问 zend View 变量

转载 作者:搜寻专家 更新时间:2023-10-31 20:51:00 24 4
gpt4 key购买 nike

如何从部分面包屑访问实际 View 中定义的变量?

我尝试使用 $this->myVar 但我什么也没得到。

我也试过这个并且有效:

$view = Zend_Layout::getMvcInstance()->getView();
echo $view->myVar

这是正确的还是有更好的方法?

最佳答案

Davi Harkness 的上述回答是 gr8,但如果您仍想像 $view->var 那样使用它,那么您甚至不需要为此使用部分 View 助手

   $view = new Zend_View();
$paths = $this->view->getScriptPaths();
$view->addScriptPath($paths[0]);
$view->name = "open source";
$test = $view->render("test.phtml");
echo $test;

其中 test.phtml 位于当前模块的/views/scripts 目录中并包含

<?php echo $this->name?>

关于php - 从部分面包屑访问 zend View 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7639544/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com