函数引见:
file_get_contents()
把整个文件读入一个字符串中。
explode()
函数应用一个字符串宰割另外一个字符串,并前往由字符串组成的数组。
count()
函数前往数组中元素的数量。
正在线视频教程分享:php视频教程
示例以下:
public function totalByFile($fullFileName) { $fileContent = file_get_contents($fullFileName); $lines = explode("\n", $fileContent); $lineCount = count($lines); for($i = $lineCount -1; $i > 0; $i -= 1) { $line = $lines[$i]; if ($line != "") break; $lineCount -= 1; //最初几行是空行的要去掉。 } unset($fileContent); unset($lines); $totalCodeInfo = new TotalCodeInfo(); $totalCodeInfo->setFileCount(1); $totalCodeInfo->setLineCount($lineCount); return $totalCodeInfo; }
相干文章教程保举:php入门教程
以上就是php统计文件中的代码行数的具体内容,更多请存眷资源魔其它相干文章!
标签: php 文件 php开发教程 php开发资料 php开发自学 统计 代码 行数
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
抱歉,评论功能暂时关闭!