在DOMDocument::loadHTML()错误中,意外结束标记p。

时间:2022-10-20 18:26:53

Why do I get warning for this code?

为什么我要对这段代码发出警告?

$content ='<p>
 <a href="http://www.we.com/1000">text </a>
 text 
 <a href="http://www.we.com/2345">text </a>
  text 
</p>

<p>text</p>

<p>
  <table border="1" cellpadding="0" cellspacing="0" dir="rtl"> 
      <tbody> 
          <tr> 
              <td>text </td> 
              <td>text </td> 
              <td>text </td> 
          </tr> 
          <tr> 
              <td>text </td> 
              <td>text </td> 
              <td>text </td> 
          </tr> 
      </tbody> 
  </table>
</p>';

$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadHTML($content);

The warning is:

警告:

Warning: DOMDocument::loadHTML(): Unexpected end tag : p in Entity, line: 25 in /home/admin/domains/we.com/public_html/refresh/lib/core.php on line 2213 <p> <a href="http://www.we.com/1000">text </a> text <a href="http://www.we.com/2345">text </a> text </p> <p>text</p> <p> </p><table border="1" cellpadding="0" cellspacing="0" dir="rtl"><tbody><tr><td>text </td> <td>text </td> <td>text </td> </tr><tr><td>text </td> <td>text </td> <td>text </td> </tr></tbody></table>

mso - fareast - font - family:宋体;mso - bidi - font - family: " times new roman "; mso - bidi - font - family: " times new roman "; mso - bidi - font - family: " times new roman "; mso - bidi - theme - font: minor - bidi ' >

1 个解决方案

#1


4  

The end tag for paragraphs is optional. A table may not appear within a paragraph. The table start tag implicitly ends that paragraph. The next paragraph end tag has no open paragraph to close.

段落的结束标签是可选的。一个表可能不会出现在段落中。表开始标记将隐式地结束该段。下一段结束标签没有打开段落关闭。

See "Tag omission in text/html" in the spec for p.

在p的规范中看到“文本/html中的标记省略”。

#1


4  

The end tag for paragraphs is optional. A table may not appear within a paragraph. The table start tag implicitly ends that paragraph. The next paragraph end tag has no open paragraph to close.

段落的结束标签是可选的。一个表可能不会出现在段落中。表开始标记将隐式地结束该段。下一段结束标签没有打开段落关闭。

See "Tag omission in text/html" in the spec for p.

在p的规范中看到“文本/html中的标记省略”。