DOMDocument::loadHTML error

前端 未结 4 1408
囚心锁ツ
囚心锁ツ 2020-12-02 11:52

I build a script that combines all css on a page together to use it in my cms. It worked fine for a long time now i i get this error:


4条回答
  •  余生分开走
    2020-12-02 12:38

    HTML5 elements are still not supported, but you can silence libxml errors completely with the $options parameter.

    Just set

    $doc = new DOMDocument();
    $doc->loadHTMLFile("html5.html", LIBXML_NOERROR);
    

    This option is preferred over @ which silences PHP errors.

    But be careful, libxml is very forgiving and it will parse a broken HTML document. If you silence libxml errors you might not even be aware that the HTML is malformed.

提交回复
热议问题