我有一个小问题:<br>
提交 PHP DomDocument 时不解析标签,例如标签。这是我的PHP代码:
$doc = new DOMDocument();
$doc->loadHTMLFile("Test.html");
$doc->formatOutput = true;
$node = new DOMElement('p', 'This is a test<br>This should be a new line in the same paragraph');
$doc->getElementsByTagName('body')->item(0)->appendChild($node);
$doc->saveHTMLFile("Test.html");
echo 'Editing successful.';
这是 HTML 代码(编辑前):
<!DOCTYPE html>
<html>
<head>
<title>Hey</title>
</head>
<body>
<p>Test</p>
</body>
</html>
(修改后)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hey</title>
</head>
<body>
<p>Test</p>
<p>This is a test<br>This should be a new line in the same paragraph</p>
</body>
</html>
为什么它不起作用?