名站网址导航为大家免费提供关于网站编程方面的知识。
PhP 使用CURL下载远程hTML文件
- 本篇文章的具体介绍如下请大家仔细看
if ($fname = $_FILES['nickname']['tmp_name']) { //获取文件的编码方式 $contents = file_get_contents($fname); $encoding = mb_detect_encoding($contents, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII')); $fp=fopen($fname,"r");//以只读的方式打开文件 $text = ""; $num = 0; if(!(feof($fp))) { $num ; $str = trim(fgets($fp)); if ($encoding != false) { $str = iconv($encoding, 'UTF-8', $str); if ($str != "" and $str != NULL) { $text = $str; } } else { $str = mb_convert_encoding ( $str, 'UTF-8','Unicode'); if ($str != "" and $str != NULL) { $text = $str; } } } while(!(feof($fp))) { $str = ''; $str = trim(fgets($fp)); if ($encoding != false) { $str = iconv($encoding, 'UTF-8', $str); if ($str != "" and $str != NULL) { $text = $text.",".$str; } } else { $str = mb_convert_encoding ( $str, 'UTF-8','Unicode'); if ($str != "" and $str != NULL) { $text = $text.",".$str; } } } } |
关于网站编程方面的知识就说道这里了,希望能够对大家有作用。,PhP,读取,TXT,中文,乱码,的,解决,方式,