1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to remove BOM with php?

Discussion in 'PHP' started by shedokan, Dec 8, 2007.

  1. #1
    is there a way to remove BOM after creation of a file?
    here's the script that I create my file with
    SEMrush
    <?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);
    }
    ?>
    PHP:
    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;
    }
    ?>
    PHP:
     
    shedokan, Dec 8, 2007 IP
    SEMrush
  2. ygadiya2000

    ygadiya2000 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2


    I have used the file and below were the file having BOM in them.



    These files had UTF8 BOM, but i cleaned them:

    administrator/components/com_virtuemart/tables/categories.php
    administrator/components/com_virtuemart/tables/products.php
    administrator/components/com_virtuemart/views/category/tmpl/edit_categoryform.php
    administrator/language/de-DE/de-DE.plg_vmcustom_specification.ini
    administrator/language/de-DE/de-DE.plg_vmpayment_heidelpay.ini
    administrator/language/en-GB/en-GB.com_jce.sys.ini
    administrator/language/en-GB/en-GB.mod_virtuemart_currencies.ini
    administrator/language/en-GB/en-GB.mod_virtuemart_manufacturer.ini
    administrator/language/en-GB/en-GB.mod_virtuemart_product.ini
    administrator/language/en-GB/en-GB.plg_vmcustom_specification.ini
    administrator/language/fr-FR/fr-FR.plg_vmcustom_specification.ini
    administrator/language/fr-FR/fr-FR.plg_vmpayment_moneybookers.ini
    administrator/manifests/files/TinyMCE_es-ES.xml
    administrator/manifests/packages/pkg_es-ES.xml
    components/com_virtuemart/assets/css/vmsite-ltr.css
    components/com_virtuemart/assets/js/languages/jquery.validationEngine-es.js
    components/new/com_virtuemart/assets/css/vmsite-ltr.css
    components/new/com_virtuemart/assets/js/languages/jquery.validationEngine-es.js
    installation-old/language/bn-BD/bn-BD.ini
    installation-old/language/lo-LA/lo-LA.ini
    installation-old/language/mk-MK/mk-MK.xml
    installation-old/language/ml-IN/ml-IN.ini
    installation-old/language/mn-MN/mn-MN.ini
    installation-old/language/sy-IQ/sy-IQ.ini
    installation-old/language/th-TH/th-TH.ini
    installation-old/language/ur-PK/ur-PK.ini
    installation-old/language/ur-PK/ur-PK.xml
    javascript/lang/calendar-br.js
    javascript/lang/calendar-el.js
    javascript/lang/calendar-fi.js
    javascript/lang/calendar-pl-utf8.js
    language/en-GB/en-GB.com_virtuemart-org.ini
    language/en-GB/en-GB.com_virtuemart.ini
    language/fr-FR/fr-FR.mod_virtuemart_category.sys.ini
    modules/mod_virtuemart_product/mod_virtuemart_product.php
     
    ygadiya2000, Nov 21, 2012 IP
  3. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #3
    Do you mean from the file after you've written it?

    writeUTF8File is adding the BOM so if that's where you want to "remove" it, just don't add it. Just comment out that line (or delete it).
    [COLOR="#008000"]//fwrite($f, pack("CCC",0xef,0xbb,0xbf));[/COLOR]
    Code (markup):
     
    Rukbat, Nov 22, 2012 IP