在我的 PHP 脚本中,我使用 md5_file()
函数为每个分析的文件返回一个 md5 key 。
但是,当文件名中有重音符号时,md5_file()
函数无法读取该文件。
//filename: Flash_Conquête_Galactic.txt
Warning: md5_file(.....): failed to open stream: No such file or directory in
我尝试使用 iconv()
函数或 utf8_encode()
函数,但都没有结果。
有什么办法可以在不修改文件名的情况下解决这个问题吗?
最佳答案
看起来 $filename 可能以某种方式被 UTF-8 编码,可能是由您的 IDE/编辑器进行的。
试试这个...
// Your filename
$filename = 'Flash_Conquête_Galactic.txt';
// Decode the string to ISO-8859-1.
$filename = utf8_decode($filename);
// Generate a hash of the files contents.
echo md5_file($filename);
关于php - 使用带有重音文件名的 md5_file() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27783528/