Mic*_*lle 1 zend-framework zend-filter-strip-tags
关于使用Zend Framework的Zend_Filter_StripTags 的setTagsAllowed和getTagsAllowed方法,我有一些非常基本的问题吗?特别:
'<h1>'或'h1'?'</h1>'?一个例子将不胜感激.
标签列表应该在哪里定义?在应用程序的控制器中?
你可以这样做.如果您可能在应用程序的其他位置重用该列表,则可能需要考虑使用Zend_Registry.
阵列是否必须包含<> ......?
只是'h1'.例如:
$allowedTags = array(
'a',
'b',
'em',
'strong'
);
Run Code Online (Sandbox Code Playgroud)
阵列是否必须包含结束标签......?
没有.
一个例子将不胜感激.
当然:
// permit only the <a>, <b>, <em> and <strong> tags
$allowedTags = array('a','b','em','strong');
// allow only the href attribute to be used in the above tags
// (which should only be within the <a> tag anyway)
$allowedAttributes = array('href');
// create an instance of Zend_Filter_StripTags to use
$stripTags = new Zend_Filter_StripTags($allowedTags,$allowedAttributes);
// now filter the string
$sanitizedInput = $stripTags->filter($userInput);
Run Code Online (Sandbox Code Playgroud)
这回答了你的问题了吗?