DOMDocument::loadHTML error

前端 未结 4 1393
囚心锁ツ
囚心锁ツ 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:52

    Header, Nav and Section are elements from HTML5. Because HTML5 developers felt it is too difficult to remember Public and System Identifiers, the DocType declaration is just:

    
    

    In other words, there is no DTD to check, which will make DOM use the HTML4 Transitional DTD and that doesnt contain those elements, hence the Warnings.

    To surpress the Warnings, put

    libxml_use_internal_errors(true);
    

    before the call to loadHTML and

    libxml_use_internal_errors(false);
    

    after it.

    An alternative would be to use https://github.com/html5lib/html5lib-php.

提交回复
热议问题