views:

41

answers:

4

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 <?php= $this->Escape($this->name);?>. But it doesn't seem to work. Zend framework forces us to use short tags no?

+1  A: 

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
Itay Moav
+1  A: 

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.

I'm asking if instead of using the short tags in the view files can I use the long tags instead? Instead of using <?= I wanted to use <?php= but it doesn't seem to work for the view files.<code>application/views/scripts/index/index.phtml<head><title>Hello Zend</title></head><pre><h1>Hello Zend</h1><p>Hello <?=$this->Escape($this->name);?> from Zend Framework</p></body></pre>
mythicalprogrammer
Using long is perfectly fine, coding practice at the job I had with the ZF did not allow for short tags. But I don't believe <?php= is a valid tag, you would have to use <?php echo perhaps that is your problem?
That's my problem it's the echo -_-;; Thank you.
mythicalprogrammer
Sweet, glad to help!
+1  A: 

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"
ArneRie
Ah but using long tags doesn't seem to work with Zend View files. I've tried it.
mythicalprogrammer
A: 

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);?>
Col. Shrapnel