Maison >développement back-end >tutoriel php > PHP读取目录含特殊字符会变成?怎么将让MYSQL正确显示插入的UTF8编码数据
PHP读取目录含特殊字符会变成?,如何将让MYSQL正确显示插入的UTF8编码数据
123.txt文件编码UTF8,浏览器页面编码UTF8,Windows系统,代码页936
新建文件夹内只有一个文件夹,文件名为http://zhidao.baidu.com/link?url=9iTctYWxBKDqzxTH-QrBs5t6Q9lhRkutHCfJHaGRNlzsswkqWsnYLdtKfCk7F_AJQwMm2yxJmoOCLDGipSjr-a这里的爱心,CSDN不让直接发出来=。=
<br /> <?php<br /> $path = iconv("UTF-8", "GBK", "F:/新建文件夹/");<br /> $dir = dir($path);<br /> $fopen = fopen("F:/123.txt", "a");<br /> <br /> while ($file = $dir->read()) {<br /> if ($file != "." && $file != "..") {<br /> $file = iconv("GBK", "UTF-8", $file);<br /> echo $file;<br /> //fwrite($fopen, $file));<br /> }<br /> }<br /> fclose($fopen);<br /> ?><br />
<br /> <?php<br /> $path = iconv("UTF-8", "GBK", dirname(__FILE__).'/新建文件夹/');<br /> $file = '123.txt';<br /> <br /> echo '<meta http-equiv="content-type" content="text/html; charset=utf-8">';<br /> echo file_get_contents($path.$file);<br /> ?><br />