Home > Backend Development > PHP Tutorial > PHP 如若要打开的文件名包含中文那么会报错

PHP 如若要打开的文件名包含中文那么会报错

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:01:07
Original
1027 people have browsed it

PHP 如果要打开的文件名包含中文那么会报错
PHP 如果要打开的文件名包含中文那么会报错

使用iconv不行
$file_read = "C:/中国.txt";

$file_read = iconv('utf-8', 'gb2312', $file_read);

会报
iconv() [function.iconv]: Detected an illegal character in input string

求教如何解决。
------解决方案--------------------
LZ PHP什么版本? 我的5.2 运行你的代码不会报错哦
错误是说 你要转换的字符串还有非法字符。你看下是哪个用'\'转义试试?
------解决方案--------------------
echo iconv('utf-8', 'gb2312//IGNORE', $file_read);

与原串对比一下少了什么

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