遍历目录,进行文件查找,发现里边的return不好使了,不知什么原因. 只能使用引用了。这年头,连return也任性,还叫人编程不??? EQPHP //类文件查找function search($directory,$class){if (!is_dir($directory)) return false;$subdirectory=array();fore
遍历目录,进行文件查找,发现里边的return不好使了,不知什么原因.
//类文件查找 function search($directory,$class){ if (!is_dir($directory)) return false; $subdirectory=array(); foreach (new DirectoryIterator($directory) as $file) { if ($file->isDot()) continue; if ($file->isDir()) { array_push($subdirectory,self::search($file->getPathName(),$class)); } else { if (pathinfo($file->getFileName(),PATHINFO_FILENAME) === $class) { return $file->getPathName(); } } } }
//类文件查找 function search($directory,$class,&$file_name){ if (!is_dir($directory)) return false; $subdirectory=array(); foreach (new DirectoryIterator($directory) as $file) { if ($file->isDot()) continue; if ($file->isDir()) { array_push($subdirectory,self::search($file->getPathName(),$class,$file_name)); } else { if (pathinfo($file->getFileName(),PATHINFO_FILENAME) === $class) { $file_name=$file->getPathName(); } } } }