你好我有问题,我在名为upload的文件夹中列出文件,当有阿拉伯语文件时显示��� ����� ������
$target = "upload";
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($target));
while($it->valid()) {
if (!$it->isDot()) {
$nom=$nom+1;
echo $it->getSubPathName();
echo '<tr align="center"><td> <a href="play.php?fil=' . $it->getSubPathName() . '">Play</a> </td><td>' . $it->getSubPathName() . '</td><td>' . $nom . '</td></tr>'; } }
答案 0 :(得分:2)
首先,将文本转换为UTF-8:
iconv('CP1256', 'UTF-8', $it->getSubPathName());
然后,确保Web浏览器正确地将页面解码为UTF-8。把它作为PHP文件的顶部:
<?php
header("Content-Type: text/html; charset=UTF-8");
// The rest of the code