0

这是我的代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gallery</title>
    <script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/lightbox.js"></script>
    <link href="css/lightbox.css" rel="stylesheet" />
</head>
<body> 
<?php
$value=$_GET["value"];
$handle = opendir("content/$value/gallery/");
while($file = readdir($handle))
{
    if($file !== '.' && $file !== '..')
    {
        do_something;
    }
}
?>

</body>
</html> 

传递值“Καθολική”,给出警告:opendir(content/Καθολική/gallery/):未能打开目录:没有这样的文件或目录。但如果我这样做:

$handle = opendir("content/Καθολική/gallery/");

它工作正常。

与字符编码有关吗?我怎么能解决这个问题?谢谢你。

4

2 回答 2

0

UTF-8 编码不支持字符集Καθολική 。尝试删除您的元 UTF-8 编码并尝试这样。

<html>
<head>
<title>Gallery</title>
    <script src="js/jquery-1.7.2.min.js"></script>
    <script src="js/lightbox.js"></script>
    <link href="css/lightbox.css" rel="stylesheet" />
</head>
<body> 
<?php
$value=$_GET["value"];
$handle = opendir("content/$value/gallery/");
while($file = readdir($handle))
{
    if($file !== '.' && $file !== '..')
    {
        do_something;
    }
}
?>

</body>
</html> 
于 2013-06-25T10:17:32.507 回答
0

试试这样

static public function read($dir, $ignore = array())
    {
        $files = scandir($dir);
        $dir_contents = array();
        foreach ($files as $file)
        {
            $pos = strpos($file, 'import');
            if ($file == '.' OR $file == '..' OR $pos !== false)
            {
                continue;
            }
            // Ignore files specified
            if ( ! in_array($file, $ignore))
            {
                $dir_contents[] = $file;
            }
        }
        return $dir_contents;
    }
于 2013-06-25T10:19:21.480 回答