How to remove multiple UTF-8 BOM sequences

后端 未结 11 2036
故里飘歌
故里飘歌 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:28

    b'\xef\xbb\xbf' stands for the literal string "\xef\xbb\xbf". If you want to check for a BOM, you need to use double quotes, so the \x sequences are actually interpreted into bytes:

    "\xef\xbb\xbf"
    

    Your files also seem to contain a lot more garbage than just a single leading BOM:

    $ curl http://ircb.in/jisti/ | xxd
    
    0000000: efbb bfef bbbf efbb bfef bbbf efbb bfef  ................
    0000010: bbbf efbb bf3c 2144 4f43 5459 5045 2068  .......

提交回复
热议问题