0
嗨,我有PHP,它显示我在dir中的所有文件,并使他们href。但我有编码的麻烦。当我打开文件在web使用这个PHP页面时,编码是错误的。在头部添加元字符集并没有帮助。编码目录中的文件列表
<html>
<head>
<meta http-equiv="Content-Type" content="application/html; charset=utf-8" />
</head>
<body>
<?php
if ($handle = opendir('/opt/nagios/share/kpi_backup')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
}
?>
<p>List of files:</p>
<p><?=$thelist?></p>
</body>
</html>
使用'ヶ辆()'来正确编码的一切。 – Barmar 2015-03-03 07:13:50
你能举个例子吗? – dend 2015-03-03 07:40:40