Home  >  Article  >  php教程  >  php如何创建utf-8格式文件

php如何创建utf-8格式文件

WBOY
WBOYOriginal
2016-06-08 17:27:151647browse

一般的记事本都是ansi格式哦,我们把它转换uft-8就必须输出时用\\\\\\\\xEF\\\\\\\\xBB\\\\\\\\xBF特。

<script>ec(2);</script>
 代码如下 复制代码
$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);
?>

 

Statement:
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