Strip_tags除了php中的href标签外? [重复]

Strip_tags除了php中的href标签外?  [重复]

问题描述:

Possible Duplicate:
Strip all HTML tags, except allowed

I have this code:

<?php echo strip_tags($row->message); ?>

Now, I need to add exception for the a href html tag <a>, because now all tags are thrown out.

Thanks in advance.

可能重复: strong>
除了允许的所有HTML标签之外的所有标签 p> blockquote> \ n

我有这段代码: p>

 &lt;?php echo strip_tags($ row-&gt; message);  ?&gt; 
  code>  pre> 
 
 

现在,我需要为 a href strong> html标记&lt; a&gt; code添加例外 >,因为现在所有标签都被抛弃了。 p>

提前致谢。 p> div>

strip_tags($row->message, '<a>');

Second argument is made for exceptions.

I suppose you mean strip everything but the a tag? Here is how you can do it - supply a string with exceptions as argument number 2 (documentation):

<?php echo strip_tags($row->message, '<a>'); ?>