<?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;
                        }
                }
        }
}

?>