<?PHPIni_set(' Max_execution_time ', ' 0 ');functionCode_linenum ($path,$i) { if(!Is_dir($path)) { return false; } $files=Glob($path. ‘/*‘); if($files) { foreach($files as $file) { if(Is_dir($file) {code_linenum ($file,$i); } $buffer= ' '; $handle= @fopen($file, ' R '); if($handle) { while(!feof($handle)) { $buffer=fgets($handle, 4096); $buffer=Trim($buffer);//equal to = = $buffer = Str_replace ("\ r \ n", "', $buffer); if(!Empty($buffer)) { $comments=Array(); $comments[0] = "; $comments[0]. =Preg_match('/\/\//i ',$buffer) ? ‘####‘ : ‘‘; $comments[0]. =Preg_match('/\/\*\*/i ',$buffer) ? ‘####‘ : ‘‘; $comments[0]. =Preg_match('/\*\s/i ',$buffer) ? ‘####‘ : ‘‘; $comments[0]. =Preg_match('/\*\//i ',$buffer) ? ‘####‘ : ‘‘; if(Empty($comments[0])) { Global $i; $i++; } } } fclose($handle); } } } return $i;}//calling FunctionsGlobal $i;$linenums= Code_linenum (' d:/guozi/v3.0 ',$i);Echo' The total number of lines of code is: '.$linenums;
PHP get code total number of rows