Recursive PHP Syntax Checker
13
Recursively checks for all *.php and *.tpl files in the directory specified (or the current directory if one is not specified) and runs `php -l $file`. Only outputs the errors.
<?php
$start_dir = (isset($argv[1])) ? $argv[1] : '.';
check_syntax($start_dir);
function check_syntax($path) {
foreach(scandir($path) as $file) {
if($file != '.' && $file != '..') {
if(is_dir("$path/$file")) {
check_syntax("$path/$file");
} else if(preg_match("/.\.(php|tpl)$/", $file)) {
$result = `php -l $path/$file`;
if($result[0] != 'N') echo $result;
}
}
}
}
?>
$start_dir = (isset($argv[1])) ? $argv[1] : '.';
check_syntax($start_dir);
function check_syntax($path) {
foreach(scandir($path) as $file) {
if($file != '.' && $file != '..') {
if(is_dir("$path/$file")) {
check_syntax("$path/$file");
} else if(preg_match("/.\.(php|tpl)$/", $file)) {
$result = `php -l $path/$file`;
if($result[0] != 'N') echo $result;
}
}
}
}
?>
Comments
Voting
Votes Up
albud
ColdKeyboard
ctiggerf
dannyboy
HardPLay
JeremyGiberson
mceppi
Pio
SecondV
shachi
Sonsam
stalfos
sundaramkumar






This script is everything I wanted and more. What with it's validation AND timing functionality, my god it's a god send.