Zend_View_Stream is used pretty much when ever you use Zend_View, and I’ve blogged about how handy it is before. But as it’s a class like any other, you can extend it to give added functionality. One such use is to add automatic escaping to your view variables when you want. So instead of doing:
<?php echo $this->escape($this->var); ?> <?= $this->escape($this->var); ?>
You could simply do:
<?=~ $this->var; ?>
That’s a lot simpler, isn’t it?
Continue reading “Extend Zend_View_Stream to easily escape view variables”