0 ) { print "$p_file : $counter\n"; } $pos = strpos( $line, "[ \$" ); if ( $pos > 0 ) { print "$p_file : $counter\n"; } break; case '-p': # parenthesis break; case '-c': # check for order of comparison ( constant == variable ) break; case '-m': # check for // comment $pos = strpos( $line, '//' ); if ( FALSE !== $pos ) { print "$p_file : $counter\n"; } break; case '-n': # check for ! with space $pos = strpos( $line, '! ' ); if ( FALSE !== $pos ) { print "$p_file : $counter\n"; } break; } # end switch } } # - --- # read in all files function process_files( $p_dir ) { $cwd = getcwd(); $cwd .= '\\'.$p_dir; chdir( $cwd ); if ( $handle = opendir( $cwd ) ) { #echo "Directory: ".getcwd()."\n"; $file_arr = array(); while (false !== ( $file = readdir( $handle ) )) { $file_arr[] = $file; } closedir( $handle ); foreach( $file_arr as $file ) { #echo "file: $file\n"; if (( '.' == $file )||( '..' == $file )||( 'CVS' == $file )) { continue; } if ( TRUE == is_dir( $file ) ) { # directory #process_files( $file ); } else { process_file( $file ); #echo "Processing: ".getcwd()."\\".$file."\n"; } } } chdir( '..' ); } # - --- function print_usage() { echo "\nUsage:\n php -q check_formatting.php