PHP counts the total number of files and lines of code in the directory, and executes the statistics of files in the directory
When skipping files: the matching rules only start from the file name, and the matching rules are also limited to beginning.
Skip comment lines in the file: The matching rules are only matched from the head of the comment paragraph. If // and *, lines starting with # and /* and blank lines appear, they will be skipped. Therefore, sweaty comments like /* must be preceded by an * sign at the beginning of each line, otherwise such comments cannot be matched.
Directory filtering: The matching rule is to match the full name of the directory name
First download the total number of files and lines of code in the PHP statistics directory we need to use for this course Several categories: //m.sbmmt.com/xiazai/leiku/542
After the download is complete, find the php class file we need, unzip it to our local directory, and create a new php file!
After completion, we need to call this class in the new php file and instantiate the class:
<?php include_once "wenjian.php";//引入类文件 $obj = new caculatefiles();//实例化 //如果设置为false,这不会显示每个文件的信息,否则显示 $obj->setshowflag(false); //会跳过所有all开头的文件 $obj->setfileskip(array('all')); $obj->run("D:/phpStudy/WWW/cv"); //所有文件,(默认格式为.php) $obj->setfileskip(array()); $obj->run("D:/phpStudy/WWW/cv"); $obj->setshowflag(true); //跳过所有i和a开头的文件,(比如接口和抽象类开头) $obj->setfileskip(array('i', 'a')); $obj->run("D:/phpStudy/WWW/cv"); ?>
The running result is as shown below:
The above is the detailed content of Example analysis of the total number of files and lines of code in the PHP statistics directory. For more information, please follow other related articles on the PHP Chinese website!