Bash Shell 对目录內 PHP 做 Syntax check

Posted by Mike on 2016-03-15

Shell script要对此目录下所有PHP做Syntax check(注:-l Syntax check only), 可以用下述写法:

*此目录內 .php 文件做Syntax check

1
2
3
for f in `ls *.php`; do
php -l $f;
done

此目录內, 所有目录含有php都做Syntax check

1
2
3
for f in `find ./ -name *.php`; do
php -l $f;
done

注:可在搭配 grep 过滤。