为什么使用DomElement与DomText时实体的处理有差异?
示例代码:
$text = 'this&that or this& that';
$document = new 'DOMDocument;
$p1 = $document->createElement('p', $text);
// versus
$p2 = $document->createElement('p');
$p2->appendChild($document->createTextNode($text));
var_dump($p1->nodeValue); // thisthat
var_dump($p2->nodeValue); // this&that or this&that
区别在于createElement
不接受标记中的(重音)和非法字符,如果是,将忽略这类字符