开发者

htmlspecialchars

if i submit data like my string using form on insert/edit view, on a list view i'll get my string as italic (like here).

how can i avoid that, and t开发者_StackOverflow社区o have my string (with visible all html tags) on all forms?

i.e. so it appears like this: <i>my string</i>

thanks in advance!


So you're asking how you can escape the HTML code on your views when you render the results as they exist in the database... is that right?

Assuming that is what you're asking, in your view, you could simply wrap the DB field output

<?php

foreach ( $rows as $row ) { 
    echo $html->tag("p",htmlentities($row['Model']['field']));
}
// or more simply
foreach ( $rows as $row ) { 
    echo htmlentities($row['Model']['field']).'<br/>';
}

?>


Maybe the option 'escape'=>true will be useful, like in:

$html->tag('p', $text, array('escape'=>true));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜