Reputation: 13757
Why is there a difference in treatment of entities when using DomElement versus DomText?
example code:
$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
Upvotes: 0
Views: 375
Reputation:
the difference is that the createElement
does not accept (accents) and illegal characters in markup and if so, will ignore this kind of character
Upvotes: 1