高手指教:中文乱码问题SOS 在PHP里我改了不行,请高手能否详细说明,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你$file_name的值是从哪里来的啊?先看看html页面的文字编码是什么,通常是gb2312或者utf-8,如果是从数据库来的话还要看该字符串在数据库里的编码,特别是mysql 4.1 之后的,没弄好很容易乱码。 程式代码(全部)<?header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\"?>"; echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""." \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; $page = $_GET['page'];include("../config.php");if (!isset($page)) {$page = 0;}$total = 0;if(!($dp = opendir("./"))) die ("不能打开网页 ./");$file_array = array(); while ($file = readdir ($dp)) { if(substr($file,0,1) != '.' and $file != "index.php") { $file_array[] = $file; } }$file_count = count ($file_array);sort ($file_array);?> <wml> <card id="card1" title="<? echo $conf["site_name"] ?>"> <p mode="nowrap"> <? echo "<a href=\"../index.php\">首页</a><br/><br/>"; ?> <? if ($file_count > 0) { $first_record = $page * $conf["items_per_page"]; $last_record = $first_record + $conf["items_per_page"]; while (list($fileIndexValue, $file_name) = each ($file_array)) { if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record)) { echo "<a href=\"$file_name\">$file_name</a> (". round(filesize($file_name)/1024,1) . "kb)<br/>"; $total = $total + filesize($file_name); } } if (($file_count > 0) AND ($last_record < $file_count)) { // next button $next_page = $page + 1; echo "<br/><a href=\"".$_SERVER['PHP_SELF']."?page=$next_page\">下一页</a><br/>"; } if (($file_count > 0) AND ($page != 0)) { // previous button $prev_page = $page -1; echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev_page\">上一页</a><br/>"; } echo "<br/>目录:<br/>$file_count "; if ($file_count == 1) {echo "文件";} else {echo "文件";} echo " (" . round($total/1024,1) . "kb)"; echo "<br/><a href=\"../index.php\">首页</a>"; } closedir($dp); ?> </p></card> </wml> 能看到中文文件列表,但是点中文文件点开或下载时所显示的URL是中文编码(不是中文字),打不开对应的中文名文件, urldecode怎么用在这个程式中,web_php能否说得详细点? echo "<?xml version=\"1.0\" ecnoding=\"UTF-8\"?>"; 另一方面如果可以,还是把你的当前页面另存为"UTF-8"格式; 还与你的操作系统有关系。如果是在LINUX下运行,中文就不可以了。 啊,我是freeBSD UNIX系统,那是没治了????? Parse error 请高手指教 怎么让程序在循环内执行110秒然后重新执行剩余没有执行完的循环? PHP连接ACCESS数据库的方法总结 function makeDir($param)...一个函数的理解,一个基础问题。。。。 数据筛选 如何使用安全的SQL搜索语句 php5.0在IIS中配置的问题 用PHP和MySql做个论坛,谁推荐一下好的论坛源码? 问如何取变量 怪!难道新浪的smtp服务器不是smtp.sina.com.cn吗?为什么会这样? 如何把正则替换出来的内容再用函数处理? mysql里面group by后统计组数
<?
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""." \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
$page = $_GET['page'];
include("../config.php");
if (!isset($page)) {$page = 0;}
$total = 0;if(!($dp = opendir("./"))) die ("不能打开网页 ./");
$file_array = array();
while ($file = readdir ($dp))
{
if(substr($file,0,1) != '.' and $file != "index.php")
{
$file_array[] = $file;
}
}
$file_count = count ($file_array);
sort ($file_array);
?>
<wml>
<card id="card1" title="<? echo $conf["site_name"] ?>">
<p mode="nowrap">
<? echo "<a href=\"../index.php\">首页</a><br/><br/>"; ?>
<?
if ($file_count > 0)
{
$first_record = $page * $conf["items_per_page"];
$last_record = $first_record + $conf["items_per_page"];
while (list($fileIndexValue, $file_name) = each ($file_array))
{
if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
{
echo "<a href=\"$file_name\">$file_name</a> (". round(filesize($file_name)/1024,1) . "kb)<br/>";
$total = $total + filesize($file_name);
}
}
if (($file_count > 0) AND ($last_record < $file_count))
{
// next button
$next_page = $page + 1;
echo "<br/><a href=\"".$_SERVER['PHP_SELF']."?page=$next_page\">下一页</a><br/>";
}
if (($file_count > 0) AND ($page != 0))
{
// previous button
$prev_page = $page -1;
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev_page\">上一页</a><br/>";
}
echo "<br/>目录:<br/>$file_count ";
if ($file_count == 1)
{echo "文件";}
else
{echo "文件";}
echo " (" . round($total/1024,1) . "kb)";
echo "<br/><a href=\"../index.php\">首页</a>";
}
closedir($dp);
?>
</p>
</card>
</wml>
另一方面如果可以,还是把你的当前页面另存为"UTF-8"格式;