本文整理匯總了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);
}