zend framework2 - Escape Html Text in ZF2 -
i have text this:
<p><strong>lorem</strong> ipsur </p>
to see text without html tags in zend framework 2 how can do?
i tried put:
<?php echo $this->escapehtml($array['text']); ?>
i read security not do:
<?php echo $array['descrizione']; ?>
im not sure if understand question, since dont know contents of arrays.
basicaly if want scape contents of variable, let's say, $input
, have call, mentioned
$this>escapehtml($input)
actually, phprenderer includes selection of helpers can use purpose: escapehtml, escapehtmlattr, escapejs, escapecss, , escapeurl.
you can read here
also, if want more control, can use zend\escaper, in 2 lines of code allow escape html, this
$escaper = new zend\escaper\escaper('utf-8'); $output = $escaper->escapehtml($input);
or escape attributes, this
$escaper = new zend\escaper\escaper('utf-8'); $output = $escaper->escapehtmlattr($input);
i recommend read 3 links, short , give better undestanding of doing.
Comments
Post a Comment