<?php
$html = '<p class="font_8" style="text-align:center; font-size:16px;"><span class="wixGuard"></span><br />
</p>';
$caption_dom = new DOMDocument;
error_reporting(E_ALL ^ E_WARNING);
$caption_dom->loadHTML($html);
error_reporting(E_ALL);
$tags_p = $caption_dom->getElementsByTagName('p');
$data = $tags_p[0]->textContent;
if(htmlentities($data) == null){
exit; //надо попасть сюда!
}
//если не попали, проверяем
$json = json_encode($data);
echo $json."<br \>";
?>
为什么\u00e2\u0080\u008b\n\u00a0
?事实上,一个换行符和一个空格应该是……一个换行符在那里是可见的\n
,但其他一切从何而来?
目的:换行符和空格应该被修剪并且想忽略这个块为空,但空不出来)
沙盒示例(含原始数据):https ://www.tehplayground.com/htWopS4E8F33ocCV
您的代码工作正常
vs code 为我强调了这些角落,我擦掉了它们并重写了它们并且一切正常
字符串为空(只有空格)
复制并粘贴,它将删除该字符 :)
https://www.tehplayground.com/wf5xMczrZyzYxUmB(PS 43 线)