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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:36:571268Durchsuche

遍历目录,进行文件查找,发现里边的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();
			}
		}
	}
}
//类文件查找
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();
			}
		}
	}
}
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn