這是一個用來檢測PHP專案中是否有相同程式碼的工具
要用PEAR安裝
1 | #將pear改成會自動搜尋相關的套件 |
2 | pear config- set auto_discover 1 |
3 | pear install pear.phpunit.de/phpcpd |
使用方法
1 | phpcpd project/ |
顯示結果(有兩個檔案5-31行是重複的)
1 | phpcpd 1.4.0 by Sebastian Bergmann. |
2 |
3 | Found 1 exact clones with 26 duplicated lines in 2 files: |
4 |
5 | - /usr/ local /www/apache22/data/zend/index.php:5-31 |
6 | /usr/ local /www/apache22/data/zend/public/index.php:5-31 |
7 |
8 | 20.80% duplicated lines out of 125 total lines of code. |
9 |
10 | Time: 0 seconds, Memory: 1.50Mb |