9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

phpのシンタックスチェック

Posted at

変更したファイルがシンタックスエラーかどうかチェックするのが面倒なのでまとめて調べる方法がないか調べてたら記事にしてくれていた人がいたので自分用にカスタマイズしたものをアップ

参考:

http://kaworu.jpn.org/kaworu/2007-11-17-2.php

#!/bin/sh
# $1 phpの文法チェックをしたいディレクトリ
#http://kaworu.jpn.org/kaworu/2007-11-17-2.php

flg=0

phpsyntaxcheck()
{
	for i in `find -E "$1" -regex '.*\.(php|inc)' `
	do
		msg=`php -l "$i"` 
		check=`echo $msg | cut -c 1-25 `
		if [ "$check" != 'No syntax errors detected' ] ; then
  			echo $msg
  			echo ''
  			flg=1
		fi
	done
}

echo ''
for i in "$@"
do
        phpsyntaxcheck "$i"
done

if [ $flg -eq 1 ] ; then
	echo 'Syntax check error!'
else
	echo 'Syntax check OK!'
fi
echo ''
9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?