Copyright statement: original works can be reproduced. During reprinting, you must mark the original publication, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan
The more at the end of the year, the more I felt that birds would not eat until early flight. <-- This sigh is not directly related to this article.
I suddenly figured out how many lines of code have been generated so far. Although this number cannot be calculated as a workload to pay, I calculated the average number of codes per day. How many codes can be regarded as a qualified software practitioner every day? What kind of code quality can be calculated as workload? How many codes will make a language unfamiliar every day? No answer to the above questions. You are welcome to provide answers.
<? Php </P> <p>/** </P> <p> * @ name count_lines.php </P> <p> * @ date mon Nov 30 20:45:50 CST 2009 </ p> <p> * @ copyright Ma yongzhan (myz) </P> <p> * @ author ma yongzhan (myz) </P> <p> * @ link http://blog.csdn.net/mayongzhan/ </P> <p> */</P> <p> set_time_limit (0 ); </P> <p> // calculate the number of rows </P> <p> function countlines ($ file) {</P> <p> return count (file ($ file )); </P> <p >}</P> <p> // recursively traverse folders </P> <p> function traversedir ($ DIR) {</P> <p> $ lines = 0; </P> <p> $ dir. = '/'; </P> <p> if ($ DH = opendir ($ DIR )) {</P> <p> while ($ file = readdir ($ DH ))! = False) {</P> <p> if ($ file! = '.' & $ File! = '.. ') {</P> <p> If (is_dir ($ dir. $ file. '/') {</P> <p> $ lines + = traversedir ($ dir. $ file); </P> <p >}</P> <p> else {</P> <p> $ lines + = countlines ($ dir. $ file ); </P> <p >}</P> <p> closedir ($ DH ); </P> <p >}</P> <p> return $ lines; </P> <p >}</P> <p> $ dirname = '/workspace/test'; </P> <p> echo traversedir ($ dirname ); </P> <p >?> <Br/>