Home > php教程 > php手册 > return “失效了”,大婶快来瞧瞧!!!

return “失效了”,大婶快来瞧瞧!!!

WBOY
Release: 2016-06-06 19:36:57
Original
1239 people have browsed it

遍历目录,进行文件查找,发现里边的return不好使了,不知什么原因. 只能使用引用了。这年头,连return也任性,还叫人编程不??? EQPHP //类文件查找function search($directory,$class){if (!is_dir($directory)) return false;$subdirectory=array();fore

遍历目录,进行文件查找,发现里边的return不好使了,不知什么原因.
只能使用引用了。这年头,连return也任性,还叫人编程不??? EQPHP
//类文件查找
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();
			}
		}
	}
}
Copy after login
//类文件查找
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();
			}
		}
	}
}
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template