2012-11-22 55 views
0

可能重複:
Strip all HTML tags, except allowedStrip_tags除了PHP中的href標籤嗎?

我有這樣的代碼:

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

現在,我需要添加例外的A HREF html標記<a>,因爲現在所有的標籤都被扔出去了。

在此先感謝。

回答

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

第二個參數是例外製成。

4

我想你的意思是剝去一切,但a標籤?這裏是你如何能做到這 - 提供有例外的字符串作爲參數號2(documentation):

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