Strip_tags除了php中的href标签外?

时间:2012-11-22 22:54:24

标签: php

  

可能重复:
  Strip all HTML tags, except allowed

我有这段代码:

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

现在,我需要为 a href html标记<a>添加例外,因为现在所有标记都被抛弃了。

提前致谢。

2 个答案:

答案 0 :(得分:8)

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

第二个论点是针对例外的。

答案 1 :(得分:4)

我想你的意思是除了a标签以外的所有东西?以下是如何执行此操作 - 提供带有例外的字符串作为参数编号2(documentation):

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