In a ZF2 application, I have a .phtml
layout containing the following:
<p>Created in 2015 <?php echo htmlspecialchars("by Jérôme Verstrynge",ENT_HTML5); ?></p>
Yet, when I check the source of returned pages, I get:
<p>Created in 2015 by Jérôme Verstrynge</p>
instead of
<p>Created in 2015 by Jérôme Verstrynge</p>
Why?
As per the manual, htmlspecialchars()
only translates &
, "
, '
, <
and >
. I think you are confusing it with htmlentities()
.
ZF2 also has an escaper view helper with a lot more options: http://framework.zend.com/manual/current/en/modules/zend.escaper.escaping-html.html