Remove BOM Header: Thinkphp Verification code cannot be displayed _php tutorial

Source: Internet
Author: User

In the Utf-8 encoded file, the BOM in the file header, occupies three bytes, used to indicate that the file belongs to the Utf-8 encoding, now has a lot of software to identify the BOM header, but also some do not recognize the BOM header, such as PHP does not recognize the BOM header, This is also the reason why the error occurs when you edit Utf-8 encoding with Notepad. The BOM is only available when the "notepad" store is stored as UTF-8 in Windows, which can be deleted with the Winhex of the first 2 bytes. In Dreamweaver inside the encoding settings can be set whether with a BOM, generally as long as PHP output is not a picture (GDI Stream), BOM will not cause problems. GDI Stream appears as a red fork if there are additional characters at the beginning.
The way to get rid of BOM head, simple is the following two kinds:
1, EditPlus to the BOM head method
After the editor is resized to UTF8 encoded format, the saved file will be preceded by a string of hidden characters (also known as BOMs), used by the editor to identify whether the file is encoded in UTF8. Run EditPlus, click Tools, select Preferences, select files, UTF-8 identity Select always delete signatures, and then edit and save php files without BOM.
2, UltraEdit removal of BOM head method
After opening the file, Save As option in the encoding format selected (Utf-8 without BOM header), OK.
For PHP programs that need to remove BOM headers can also be removed using the bom.php program under the directory.

  ";} else{$dirname = $basedir. " /". $file; Checkdir ($dirname);}} End Whileclosedir ($DH);} End if ($dh}//end functionfunction Checkbom ($filename) {global $auto; $contents = file_get_contents ($filename); $ CHARSET[1] = substr ($contents, 0, 1), $charset [2] = substr ($contents, 1, 1); $charset [3] = substr ($contents, 2, 1); if (Ord ($c HARSET[1] = = 239 && ord ($charset [2]) = = 187 && ord ($charset [3]) = = 191) {if ($auto = = 1) {$rest = substr ($co Ntents, 3); rewrite ($filename, $rest); return "BOM found, automatically removed.";} Else{return ("BOM found.");}} else return ("BOM not Found.");} End Functionfunction Rewrite ($filename, $data) {$filenum = fopen ($filename, "w"); Flock ($filenum, LOCK_EX); Fwrite ($ FileNum, $data); fclose ($filenum);}? >


http://www.bkjia.com/PHPjc/755769.html www.bkjia.com true http://www.bkjia.com/PHPjc/755769.html techarticle In the Utf-8 encoded file, the BOM in the file header, occupies three bytes, used to indicate that the file belongs to Utf-8 encoding, now has a lot of software to identify the BOM header, but also some do not recognize the BOM head, ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.