2
我試圖用strip_tags
和trim
來檢測一個字符串是否包含空html?PHP的html_entity_decode和修剪混淆
$description = '<p> </p>';
$output = trim(strip_tags(html_entity_decode($description, ENT_QUOTES, 'UTF-8')));
var_dump($output);
字符串 'A'(長度= 2)
我的調試嘗試算出這個:
$description = '<p> </p>';
$test = mb_detect_encoding($description);
$test .= "\n";
$test .= trim(strip_tags(html_entity_decode($description, ENT_QUOTES, 'UTF-8')));
$test .= "\n";
$test .= html_entity_decode($description, ENT_QUOTES, 'UTF-8');
file_put_contents('debug.txt', $test);
輸出:DEBUG.TXT
ASCII
<p> </p>
屍體解剖在這方面是一個很棒的詞。 – Martin