Home > Backend Development > PHP Tutorial > PHP生成UTF8文件的方法_PHP

PHP生成UTF8文件的方法_PHP

WBOY
Release: 2016-06-01 12:18:16
Original
818 people have browsed it
复制代码 代码如下:
$f=fopen("test.txt", "wb");
$text=utf8_encode("a!");
//先用函数utf8_encode将所需写入的数据变成UTF编码格式。
$text="\\xEF\\xBB\\xBF".$text;
//"\\xEF\\xBB\\xBF",这串字符不可缺少,生成的文件将成为UTF-8格式,否则依然是ANSI格式。
fputs($f, $text);
//写入。
fclose($f);
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template