本文整理汇总了PHP中FileUtils::getPHPfile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtils::getPHPfile方法的具体用法?PHP FileUtils::getPHPfile怎么用?PHP FileUtils::getPHPfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils::getPHPfile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPHPfile
/**
*
* @param php项目文件夹路径 $dirpath
* @return array of phpfiles
*/
public static function getPHPfile($dirpath)
{
$ret = array();
if (substr($dirpath, -4) == ".php") {
$in_charset = mb_detect_encoding($dirpath);
$dirpath = iconv($in_charset, "UTF-8", $dirpath);
array_push($ret, $dirpath);
}
if (!is_dir($dirpath)) {
return $ret;
}
$dh = opendir($dirpath);
while (($file = readdir($dh)) != false) {
// 文件名的全路径 包含文件名
$filePath = $dirpath . "/" . $file;
// echo $filePath."<br/>";
if ($file == "." or $file == "..") {
continue;
} elseif (is_dir($filePath)) {
$files = FileUtils::getPHPfile($filePath);
foreach ($files as $filePath) {
if (!is_null($filePath)) {
$in_charset = mb_detect_encoding($filePath);
$filePath = iconv($in_charset, "UTF-8", $filePath);
array_push($ret, $filePath);
}
}
} elseif (substr($filePath, -4) == ".php") {
$in_charset = mb_detect_encoding($filePath);
$filePath = iconv($in_charset, "UTF-8", $filePath);
array_push($ret, $filePath);
}
}
closedir($dh);
return $ret;
}
示例2: str_replace
$project_path = str_replace(array('\\', '//'), '/', $project_path);
$scan_path = str_replace(array('\\', '//'), '/', $scan_path);
$fileName = str_replace('/', '_', $scan_path);
$fileName = str_replace(':', '_', $fileName);
$serialPath = CURR_PATH . "/data/resultConetxtSerialData/" . $fileName;
if (!is_file($serialPath)) {
//创建文件
$fileHandler = fopen($serialPath, 'w');
fclose($fileHandler);
}
$results = null;
if (($serial_str = file_get_contents($serialPath)) != '') {
$results = unserialize($serial_str);
} else {
//3、初始化模块
$allFiles = FileUtils::getPHPfile($project_path);
$mainlFiles = FileUtils::mainFileFinder($scan_path);
$initModule = new InitModule();
$initModule->init($project_path, $allFiles);
//4、循环每个文件 进行分析工作
if (is_file($project_path)) {
load_file($project_path);
} elseif (is_dir($project_path)) {
$path_list = $mainlFiles;
foreach ($path_list as $path) {
try {
load_file($path);
} catch (Exception $e) {
continue;
}
}
示例3: getAllSourceFiles
private function getAllSourceFiles()
{
return FileUtils::getPHPfile($this->path);
}