开发者

Do no not want Zend Framework View's short tag. Is there an alternative to $view->setUseStreamWrapper(true)?

I'm trying to learn the Zend Framework, my first framework, and I came across the View section. In order to out put stuff from the controller to the view, I have to use short tags. I don't want to do this because of XML. The only option, I've found so far, is $view->setUseStreamWrapper(true) which apparently kills performance. I was wondering if there is any alternative solutions (other than $view->setUseStreamWrapper(true))?

Thank you in advance.

Sorry here's a clarification:


application/views/scripts/index/index.phtml

`Escape($this->name);?> from Zend Framework


Instead of <?=$this->Escape($this->name);?>, I want to use the long tags开发者_如何学JAVA <?php= $this->Escape($this->name);?>. But it doesn't seem to work. Zend framework forces us to use short tags no?


You can use

<?php echo $this->escape($this->name); ?>

or if you want to use short tags, you can set it on most servers in your .htaccess

php_value "short_open_tag" "on"


I am not exactly sure what you are asking, but you do not have to use short tags, you can use long ones. You can also use short tags without using $view->setUseStreamWrapper(true), you simply need to turn on short tags in your php.ini (you may also be able to set it in your script, but I am not sure) I believe all $view->setUseStreamWrapper(true) does is pre parse your script and turn <? into <?php.
As for performance degradation, it was my experience that the ZF was slow no matter what you do. It seems the Zend people put a TON of stuff in the framework that has no business being in there, it seems that it is just a huge beast that tries to do everything, and so it end up doing it all poorly. Could just be me though.


If you mean the <? Then no, you don't have to use them, you can use them. Just use <?php instead.
I do not see how $view->setUseStreamWrapper is connected to the question.

<?=

will translate to

<?php echo


I want to use the long tags Escape($this->name);?>

This is not long nor valid tag. There is no such syntax in PHP
If you want to use long tags, you have to make it

<?php echo  $this->Escape($this->name);?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜