当php需要时,php脚本扫描父目录而不是其所在的目录

当php需要时,php脚本扫描父目录而不是其所在的目录,php,arrays,apache,file,require,Php,Arrays,Apache,File,Require,好的,我有一个满是照片的目录 在该目录中,我有以下脚本: <?php // These files will be ignored $excludedFiles = array ( '' ); // These file extensions will be ignored $excludedExtensions = array ( 'html', 'htm', 'php', 'css' ); // Make sure we ignore . and .. $excludedF

好的,我有一个满是照片的目录

在该目录中,我有以下脚本:

<?php


// These files will be ignored
$excludedFiles = array (
  ''
);

// These file extensions will be ignored
$excludedExtensions = array (
'html',
'htm',
'php',
'css'
);

// Make sure we ignore . and ..
$excludedFiles = array_merge($excludedFiles,array('.','..')); 

// Convert to lower case so we are not case-sensitive
for ($i = 0; isset($excludedFiles[$i]); $i++) $excludedFiles[$i] =  strtolower(ltrim($excludedFiles[$i]));
for ($i = 0; isset($excludedExtensions[$i]); $i++) $excludedExtensions[$i] = strtolower($excludedExtensions[$i]);

// Loop through directory
$count = 0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
  $extn = explode('.',$file);
  $extn = array_pop($extn);
  // Only echo links for files that don't match our rules
  if (!in_array(strtolower($file),$excludedFiles) && !in_array(strtolower($extn),$excludedExtensions)) {
    $count++;
    print("<a href='#' rel='" . $file . "' class='image'><img src='" . $file . "' class='thumb' border='0'/></a>");
    }
  }
  ;
  closedir($handle);
 }

?>

if($handle=opendir('..'){
替换为
if($handle=opendir('./gallery/){
){

哇,我是个白痴,我在发帖前就试过了,但没用,但我明白了原因,又试了一次,在查看源代码后我明白了原因!