Nate
Nate

Reputation: 28384

How to count the number of lines in php files?

I am working on a php application and would like to know the number of lines in the files. The files are in a couple of different directories, but I can copy them all to one directory if needed.

What's the best Windows application/tool to count the number of lines in the files?

I've searched on here, but almost all of the questions were about counting in php, not using an external program.

Thank!

Upvotes: 1

Views: 3063

Answers (3)

tskuzzy
tskuzzy

Reputation: 36466

If you have access to a Linux shell, you can run this command:

find . -name '*.php' -exec cat {} \; | wc -l

If you're on Windows, install Cygwin first and then run the command.

Upvotes: 4

Lusitanian
Lusitanian

Reputation: 11122

CLOC is an extremely powerful tool that does what your asking and separates lines of code, blank lines and comments.

Upvotes: 8

mario
mario

Reputation: 145482

If you don't want to use count(file($fn)) then external tools would also be feasible.

A standard Unix tool is wc wordcount. With the -l option just returns lines:

 $count = intval(`wc -l '$fn'`);

Don't forget escaping. And yes, you can google for a Windows version.

Upvotes: 1

Related Questions