How to remove multiple UTF-8 BOM sequences

后端 未结 11 1764
故里飘歌
故里飘歌 2020-11-22 10:28

Using PHP5 (cgi) to output template files from the filesystem and having issues spitting out raw HTML.

private function fetch($name) {
    $path = $this->         


        
11条回答
  •  粉色の甜心
    2020-11-22 11:08

    try:

    // -------- read the file-content ----
    $str = file_get_contents($source_file); 
    
    // -------- remove the utf-8 BOM ----
    $str = str_replace("\xEF\xBB\xBF",'',$str); 
    
    // -------- get the Object from JSON ---- 
    $obj = json_decode($str); 
    

    :)

提交回复
热议问题