DOMTemplate::__construct PHP Method

__construct() public method

* new DOMTemplate : instantiation --------------------------------------------------------------------------------------------------------------
public __construct ( $source, $namespaces = [] )
    public function __construct($source, $namespaces = array())
    {
        //detect the content type; HTML or XML. HTML will need filtering during input and output
        //does this source have an XML prolog?
        $this->type = substr_compare($source, '<?xml', 0, 4, true) === 0 ? self::XML : self::HTML;
        //load the template file to work with,
        //it _must_ have only one root (wrapping) element; e.g. `<html>`
        $this->DOMDocument = new DOMDocument();
        if (!$this->DOMDocument->loadXML($this->type == self::HTML ? "<?xml version=\"1.0\" encoding=\"utf-8\"?>" . self::toXML($source) : $source, @LIBXML_COMPACT || @LIBXML_NONET)) {
            trigger_error("Source is invalid XML", E_USER_ERROR);
        }
        //set the root node for all XPath searching
        //(handled all internally by `DOMTemplateNode`)
        parent::__construct($this->DOMDocument->documentElement, $namespaces);
    }