最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
file_get_contents 中文路径报错问题解决
时间:2022-06-24 23:14:03 编辑:袖梨 来源:一聚教程网
解决file_get_contents遇到中文文件名无法打开问题
比如:受访页面_20151202-20151202.csv
file_get_contents(受访页面_20151202-20151202.csv)就会报错
[function.file-get-contents]: failed to open stream: No such file or directory
改成不用包含中文的文件名路径就可以。
原因:
编码问题,Windows中是使用gbk中文编码的,而PHP文件一般都是用utf-8格式保存的了。中文地址获取之前做一次iconv('utf-8', 'gbk', $path)就没有问题了。
$path='/baidu/受访页面_20151203-20151203.csv';
$path=iconv('utf-8', 'gbk', $path);
$content= file_get_contents($path);
echo $content;
?>
相关文章
- 王者荣耀新宫本武藏连招操作 2022新版宫本怎么玩攻略[多图] 05-08
- 代号鸢左慈紫藤醉日怎么样 05-08
- 塞尔达传说王国之泪大的佐纳乌能源获得方法攻略 05-08
- paypal官网安卓版2024 05-08
- 代号鸢左慈紫藤醉日怎么样 代号鸢5.9新地宫介绍 05-08
- 虎符交易所最新安卓版2024 05-08