在zend框架中$ this-> escape()实际上做了什么?

Ind*_*ler 13 php zend-framework zend-view

我需要帮助理解Zend Framework中辅助函数的实际操作.

我需要有人向我解释在$this->escape($string)将字符串打印到模板之前对传递给它的字符串实际做了什么.

sak*_*ako 17

$this->escape()根据您可以提供的设置转义字符串$this->setEscape('functionname'),默认情况下它是PHP的htmlspecialchars函数.

http://framework.zend.com/manual/en/zend.view.scripts.html


Der*_*huk 7

它调用htmlspecialchars PHP函数.

执行的翻译是:

  • '&'(&符号)变为'&'
  • '''(双引号)变为'''''
  • '<'(小于)成为'<'
  • '>'(大于)变为'>'