PHP DomDocument output without <?xml version=“1.0” encoding=“UTF-8”?>

后端 未结 4 783
心在旅途
心在旅途 2020-12-10 01:01

is there an option with DomDocument to remove the first line:


The class instantiation auto

4条回答
  •  盖世英雄少女心
    2020-12-10 01:38

    You can use output buffering to remove it. A bit of a hack but it works.

    ob_start();
    
    // dom stuff
    
    $output = ob_get_contents();
    ob_end_clean();
    
    $clean = preg_replace("/(.+?\n)/","",$output);
    

提交回复
热议问题