日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php html_entity_decode 标签没有闭合,php – strip_tags和html_entity_decode组合无法按预期工作...

發(fā)布時間:2025/3/20 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php html_entity_decode 标签没有闭合,php – strip_tags和html_entity_decode组合无法按预期工作... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我從昨天起就一直在與這個問題作斗爭 – 不幸的是無濟于事(并非完全沒有,我找到了某種解決方法),經過一些研究和重讀文檔后,我仍然沒有多少目瞪口呆和困惑.

讓我們假設有一個丑陋的字符串,它已經具有正確的html編碼的特殊字符.像這樣 :

$exampleString = '<div id="dynamic2"> <div

id="iStoreProductLongDescription" class="iStoreBox">

<div class="iStoreBoxWrapper"> <div

class="iStoreBoxContent"> <p style="text-

align:justify;"> </p> <p style="text-

align:justify;"><span style="font-

size:large;"><span> Just a bunch of text here, at

the end. yedyedyed';

現(xiàn)在我想把這個字符串輸出為一個簡單,干凈的字符串,所以首先我需要將它轉換為html標簽,然后剝離標簽.所以我猜以下鏈應該有效:

$result = strip_tags(htmlspecialchars_decode($exampleString));

但事實并非如此,在網(wǎng)絡的來源中echo $的結果是:

<div id="dynamic2"> <div id="iStoreProductLongDescription" class="iStoreBox"> <div class="iStoreBoxWrapper"> <div class="iStoreBoxContent"> <p style="text-align:justify;"> </p> <p style="text-align:justify;"><span style="font-size:large;"><span> Just a bunch o text here, at the end. yedyedyed

在用戶輸出中,html標簽是可見的并且保持不變.但是,當我做這樣的事情時:

$result = strip_tags(html_entity_decode(htmlspecialchars_decode($exampleString)));

然后它像魅力一樣工作,并向用戶輸出所需的字符串,同樣在web源中:

Just a bunch o text here, at the end. yedyedyed

問題是 – 為什么不

strip_tags(htmlspecialchars_decode($exampleString));

工作(我認為)它應該工作?

任何見解都非常感激.

干杯

解決方法:

如果你仔細觀察,你會看到你有

&放大器;放大器; LT;并且它不是& lt;.

所以,你首先htmlspecialchars_decode只是轉換

&放大器;放大器; LT;到& lt;

這肯定是一個特殊的實體,以后可以用第二次運行的htmlspecialchars_decode(或html_entity_decode)解碼為

標簽:php,html

來源: https://codeday.me/bug/20190609/1201958.html

總結

以上是生活随笔為你收集整理的php html_entity_decode 标签没有闭合,php – strip_tags和html_entity_decode组合无法按预期工作...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。