已解决:PHP用echo输出中文到文件日志乱码的问题

我的情况是想将一个输出结果重定向到一个文件,php test.php > test.log 然后看test.log的情况,然后发现中文乱码。在phpstorm中进行操作
解决方案。

  1. echo mb_convert_encoding('中文','gbk','utf-8');
  2. iconv("GBK","UTF-8",'中文');

两种方式都可以试一下

猜你喜欢

转载自blog.csdn.net/qq_21891743/article/details/134284986