Home > Backend Development > PHP Tutorial > PHP 关于fopen读取带有特殊字符文件名问题

PHP 关于fopen读取带有特殊字符文件名问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:12:12
Original
1655 people have browsed it

例如我的文件名是:上海“1+1”峰会的 [报告及评估].pdf
求一个解决办法;

回复内容:

例如我的文件名是:上海“1+1”峰会的 [报告及评估].pdf
求一个解决办法;

<code><?php $string = '上海“1+1”峰会的 [报告及评估].txt';
$string = iconv('UTF-8','GB2312',$string);

$file = fopen($string,'r');
echo fgets($file);
</code></code>
Copy after login

我写了一个demo,其实中间只需要进行一次字符串转化,转化为gb2312就可以了

<code>$string = '上海“1+1”峰会的 [报告及评估].pdf';
$string = iconv('UTF-8','GB2312',$string);
</code>
Copy after login

修改(GB2312改为了GBK,好像就解决了):

<code>$str = './粤食药监办科﹝2016﹞115号 关于印发推进“互联网+食品药品监管”的实施方案的通知.txt';

$str = iconv('UTF-8','GBK',$str);
$file = fopen($str,'r');
echo fgets($file);
</code>
Copy after login
Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template