2016-11-04 108 views
-1

我想從以下字符串中刪除引號和HTML標籤:卡住strip_tags爲什麼不能在我的代碼中工作?

$mystring='Example string "I want to remove any html tags ABC<sub>DE</sub> from <p>similar</p> types of string?"'; 

我使用下面的腳本來刪除它,但它是對我不起作用:

echo strip_tags(htmlentities($mystring,ENT_QUOTES)); 

我想下面的輸出對於上面的字符串:

Example string "I want to remove any html tags ABCDE from similar types of string?" 

爲什麼strip不起作用?我在這裏弄到了什麼?

回答

0

在第一次使用如果你想刪除HTML標籤,然後使用ヶ輛如下它應該是工作用strip_tags功能:

echo htmlentities(strip_tags($mystring),ENT_QUOTES); 
+0

我必須從字符串中脫離單引號或雙引號以及條形標記。該腳本正常工作。謝謝 – ThoHua

7

一旦您在該字符串上使用htmlentities(),則沒有標籤可以剝離,因爲它們已被轉換爲HTML實體。

+0

同意.. .... ... – devpro

0

您可以使用此代碼

echo strip_tags($mystring); 
相關問題