成都创新互联网站制作重庆分公司

检查整个目录php语法错误脚本

其实也可以检查其他语言的语法错误,把代码内的php -l 换了就行

公司主营业务:网站建设、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出新安免费做网站回馈大家。

#! /bin/bash
#
# check_php_syntax.sh
# Copyright (C) 2014 
#
# Distributed under terms of the MIT license.
#


#!/bin/bash
# check php syntax 
if [ $# -lt 1 ];then
    echo 'Usage: ' $0  'directory';
    exit
fi
if [ ! -d $1 ];then
    echo $1  'not a directory,please check!';
    exit
fi
directory=$1
echo $directory
temp_file="/tmp/file$$"
echo $temp_file

ls -R $directory | awk  '
BEGIN{
FS="n"    
folder="'$directory'"
logname="'$temp_file'"
temp=""
}

{
    if($0~/.php$/){
        system("php -l " folder "/" $0  "   >>  " logname  " 2>&1")  
    }
    if($0~/:$/){
        temp=substr($0,1,length($0)-1)
        folder=temp
    }
}
'
#folder=substr($1,1,length($1)-1)
if [ -e $temp_file ];then
    cat $temp_file | awk '
    BEGIN{
    error = 0
}
{
    if($0~/Parse/) {
        error++ 
        errorfile[$0] = $0
    }   
}
END{
print "错误文件:" error "个"
if(length(errorfile)>0) print "错误行数:"
    for (i in errorfile)
        print i
    }
    '
else
    echo "php file not found."
    exit;
fi

分享文章:检查整个目录php语法错误脚本
当前链接:http://cxhlcq.com/article/geppdo.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部