您现在的位置是:首页 > 后端 > PHP网站首页PHP
php检测文件编码
- PHP
- 2018-11-06
- 2249已阅读
- 0
简介php检测文件编码: /** * 检测文件编码 * @param string $file 文件路径 * @return string|null 返回 编码名 或 null
php检测文件编码:
/** * 检测文件编码 * @param string $file 文件路径 * @return string|null 返回 编码名 或 null */ function detect_encoding($file) { $list = array('GBK', 'UTF-8', 'UTF-16LE'); $str = file_get_contents($file); foreach ($list as $item) { $tmp = mb_convert_encoding($str, $item, $item); if (md5($tmp) == md5($str)) { return $item; } } return null; }
上一篇:安装weiphp遇到的问题
下一篇:php输出缓冲flush不起作用