Jump to content

how to remove BOM with php?


shedokan

Recommended Posts

is there a way to remove BOM after creation of a file?

here's the script that I create my file with

<?php
function writeUTF8File($filename,$content) {
        $f=fopen($filename,"w");
        # Now UTF-8 - Add byte order mark
        fwrite($f, pack("CCC",0xef,0xbb,0xbf));
        fwrite($f,$content);
        fclose($f);
}
?>

I found this function but I don't know how to use it:

<?php
function removeBOM($str=""){
        if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) {
                $str=substr($str, 3);
        }
        return $str;
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/80756-how-to-remove-bom-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.