PHP

How to solve error: ‘PHP Warning: DOMDocument::createElement(): unterminated entity reference’ when creating a new element using the DOMDocument object model

Written by Ian Carnaghan · 13 sec read >
  • Knowledge Base
  • Programming
  • PHP
  • How to solve error: 'PHP Warning: DOMDocument::createElement(): unterminated entity reference' when creating a new element using the DOMDocument object model

DOMDocument = Represents an entire HTML or XML document; serves as the root of the document tree.  (PHP 5)
DOMDocument::createElement()  Create new element node. (PHP 5)

Now to the solution!

Solution:

  • Use the htmlentitites function to convert all applicable characters to HTML entities.
  • $dom->createElement(‘value’, htmlentities($text_value));
    • htmlentitites Convert all applicable characters to HTML entities (PHP 4, PHP 5)

Problem should be solved!

Last Updated On March 22, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. In my spare time I teach undergraduate classes in web development. Profile

Leave a Reply

avatar
  Subscribe  
Notify of