codice:
function contaf($pathToDir){
	$nf=0;
	$handle = opendir($pathToDir);
	while (false !== ($file = readdir($handle))) {
		if($file!='.' AND $file!='..' AND !is_dir($pathToDir.$file)){
			$nf++;
		}
	}
	return $nf;
}
//esempio
echo contaf('./');