如何在 Zend 框架中将 view.php 文件作为 json 对象获取?现在我在控制器中使用它:
// in controller
public function helloAction()
{
$this->view->meta->title = 'Hello';
$this->view->meta->keywords = 'hello, wold, freebies';
$this->view->meta->description = 'Blah blah blah';
$this->render();
}
// in view *hello.php*
<div class="hello">Hello world</div>
我想hello.php
在变量中捕获该内容,就像这样
$html = $this->render();
$this->view->content = $html;
所以,使用这个?render=json我期待这样的结果
[view] => stdClass Object
(
[meta] => stdClass Object
(
[title] => Hello
[description] => hello, wold, freebies
[keywords] => Blah blah blah
)
[content] => stdClass Object
(
[view] => <div class="hello">Hello world</div>
)
)
这怎么可能?