检查php语法 syntax check
php -l test.php
在git commit前检查php语法,防止提交到生产环境
#!/bin/bash
#loop trough the modified files
for file in $(git diff-index --name-only HEAD); do
if [[ $file =~ ".php" ]]; then
echo $file
message=$(php -l $file)
if [[ $message == *error* ]]; then
echo "Commit failed. Please fix errors and recommit."
exit 1;
fi
fi
done;