如何将zend phtml文件包含到其他phtml文件中

php*_*r12 3 php zend-framework

我使用zend框架1.

我需要在另一个文件中包含phtml文件并将参数发送到第一个文件.

例如:

我有indexController.php

$numberOfItem在控制器内部定义了

我需要 在index.phtml中渲染(包含) menu.phtml并向其发送变量$numberOfItem

谢谢

Osa*_*awe 7

你可以使用zend partial来做到这一点

index.phtml

echo $this->partial('yourfolder/menu.phtml', array('numberOfItem' => $numberOfItem));
Run Code Online (Sandbox Code Playgroud)

在您的menu.phtml中,您可以使用读取打印变量

$this->numberOfItem
Run Code Online (Sandbox Code Playgroud)