PHP - How to count lines of code in an application -


this question has answer here:

i need count number of lines of code within application (in php, not command line), , since snippets on web didn't much, i've decided ask here. reply!

edit

actually, need whole snippet scanning , counting lines within given folder. i'm using method in cakephp, i'd appreciate seamless integration.

to on directory, i'd use iterator.

function countlines($path, $extensions = array('php')) {     $it = new recursiveiteratoriterator(         new recursivedirectoryiterator($path)     );     $files = array();     foreach ($it $file) {         if ($file->isdir() || $file->isdot()) {             continue;         }         $parts = explode('.', $file->getfilename());         $extension = end($parts);         if (in_array($extension, $extensions)) {             $files[$file->getpathname()] = count(file($file->getpathname()));         }     }     return $files; } 

that return array each file key , number of lines value. then, if want total, array_sum(countlines($path));...


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -