If we use fopen directly to create will find that the file encoding is not a uft-8, then if you want to create a uft8 file we need some technical processing, below I searched some common methods on the network, let's take a look. use PHP to create the encoding format u... if we use fopen directly to create will find that the file encoding is not a uft-8, then if you want to create a uft8 file we need some technical processing, below I searched some common methods on the network, let's take a look.
Use PHP to create a UTF-8 file:
Step 1: Create a txt file, open, File-> save as xxx. php, and change the encoding to UTF-8, save.
Part 2: Add the following code to the PHP file:
Use this method to create the key points of the UTF-8 encoding file, ensure that the PHP code file encoding format is UTF-8, php code file encoding format is what is the file encoding created is what.
There are three main reasons to control the display of the page:
1. HTML code control: the head label in the standard HTML webpage file contains this code.
In the code, charset = utf-8 tells the browser to display the content in the webpage in UTF-8 format.
2. PHP code control: if header ("content-Type: text/html; charset = utf-8") is added at the beginning of the PHP file, it is also used to tell the browser to display the content in the webpage in UTF-8 format. (Note: No echo-like output can be provided before this code)
3. file physical storage property control: open a file in notepad, and save the file as. what you see in "encoding" is the real encoding of the current file.
Add a fopen example with the following code:
The file encoding format created in this way is indeed UTF-8, but the Chinese characters in the file are garbled. after some debugging, the code is as follows:
I do not understand why this string is added to "\ xEF \ xBB \ xBF.