Copy the code The code is as follows:
$f=fopen("test.txt", "wb");
$text=utf8_encode("a!");
//First Use the function utf8_encode to convert the data to be written into UTF encoding format.
$text="\xEF\xBB\xBF".$text;
//"\xEF\xBB\xBF", this string of characters is indispensable, the generated file will be in UTF-8 format, otherwise it will still be in ANSI format.
fputs($f, $text);
//Write.
fclose($f);
?>
The above introduces the efficacy and function of American ginseng slices and how to consume them. The method of generating UTF8 files with PHP includes the efficacy and role of American ginseng slices and how to consume them. I hope it will be helpful to friends who are interested in PHP tutorials.