Scanning a Directory For PHP Errors

My fellow web geeks might find this script, php‐check download home on the range movie , useful. It recursively scans a directory checking PHP files for syntax errors.

Just copy it somewhere in your path (like /usr/local/bin) and chmod it to 755.

I wrote the script because I edit PHP using Notepad++, so it’s easy for small typos to enter my scripts. I needed a quick way to scan a directory after uploading revised files.
I wrote it in PHP so that those who need it will also know how to customize it.

?php // php‐check version 1.0 // recursively scans a directory for .php files and runs php -l on // them (php -l checks for PHP syntax errors) // revisions at if (php_sapi_name()!=‘cli’) { die(“This utility can only be run from the command line.\n”); } $counter=0; $errors=false; function scan_dir($dir) { $counter=0; $dh=opendir($dir); while ($file=readdir($dh)) { if ($file==’.’ || $file==’..’) continue; if (is_dir($dir.’/’.$file)) { $counter+=scan_dir($dir.’/’.$file); } else { if (substr($file, strlen($file) — 4) == ‘.php’) { $counter++; $output=shell_exec(“/usr/bin/php -l $dir/$file 2>&1”);
if (substr($output,0,2)!=‘No’) { // skips the “No syntax errors in …” message
echo $output;

return $counter;
if ($argc!=2) {
die(“Usage: php‐check dirname (usually php‐check .)\n”);

if (!is_dir($argv[1])) {
die(“Argument must be a directory. The most common usage is php‐check .\n”);


echo “$counter files checked\n”;

This is a quick and dirty script — there are probably some bugs in it. User beware.

If you find it helpful, you might also want to check out scripts like PHP CodeSniffer

or PHP robot chicken star wars dvd

Me And The Mythbusters

I recently submitted a question to the Freakonomics guys for an interview with the MythBusters.

They picked my question as the first one!

Here’s my question and their answer:

Me: Could you describe the brainstorming process that goes into an episode? How far in advance do you begin planning? Who sits in during those meetings?

ADAM: The usual crowd at a brainstorming session is me, Jamie, Alice Dallow (our producer), and whichever researcher is doing the segment we’re working on — either Dennis Kwon or Eric Haven. We also have an on‐the‐ground executive producer during an official “story meeting.” We usually have one or maybe two of them before shooting a myth, but discussions about stories can happen all over the place, and at any time.

Often, we’ll ask for certain parameters as far as locations or materials, and as we discover what’s possible or not possible, we’ll hone it down to what we’re actually going to do. The show’s researchers are fantastic about finding the weirdest of things and experts, and Alice is brilliant at keeping us on track. The discussions can be like herding cats — there’s a ribald, funny atmosphere, and we’ll range very far from the topic at hand.

Planning can take anywhere from a month to a day or two, depending on the schedule. We’ve had critical locations fall through at the last minute, and needed to turn 180 degrees on a few hours’ notice. We’ll also flag difficult stories as far in advance as we think necessary. Some things, like getting permission to film at Giants Stadium for the Jimmy Hoffa story, have taken the better part of a year to work out.

Then there’s the discussions that Jamie and I have. We’ll often take a difficult problem home, think about it overnight, and maybe discuss the problems we see in it while driving to a location. We also play devil’s advocate with each other — if one of us has a good idea, the other will poke as many holes in it as possible, and in this way we try our best to shake out any problems before we hit them.

JAMIE: This is, believe it or not, the most fun we have on the show. There is no underestimating the thrill of a big catastrophe or explosion; but if you really want to know what gets us going, it’s the brainstorming. Once a topic has passed muster, some basic research has been done by our research team, and we are down to nutting it out, Adam and I swing into action — sort of. Usually we go home first and think about it overnight, and then come in bursting with ideas. We set up in front of a dry erase board, and lay out any solutions we came up with by ourselves.

Amazingly, as much as we are of different temperaments, we quickly spot the best solutions and chip in to flesh the approach out. It becomes like playing Ping‐Pong with ideas. Sometimes it gets so intense that there is no time to complete sentences; it becomes a bunch of gesticulations, some pieces of words or phrases, and then, when we come out on the other end, the approach is fleshed out. We call it the “MythBusters Mindmeld.” To anyone listening, it is gibberish, but it allows us to plow through a huge amount of designing in no time (which is what we have a lot of on the show).

Read the rest of the interview.

Some Thoughts On Servant Leadership

At a Chi Alpha conference in St. Louis I just heard Dick Schroeder use an interesting phrase to compliment someone — “he puts ‘us’ before ‘me’.” Here are some off‐the‐cuff and unpolished thoughts inspired by that phrase:

“Us before me.” What a beautiful phrase to describe servant leadership.

“Us” puts the leadership into servanthood: “us before me” leads to the overall good of the group whereas “you before me” can lead to the detriment of the group.

To be clear, the Bible does command us to “in humility consider others better than ourselves” (Philippians 2:3). Doesn’t this lead directly to “you before me”?

Yes. It does. But the practical question for me as a leader is how to be self‐sacrificial in a way that honors my obligations to those I am serving. And I have learned that there is a healthy way to prioritize others and a destructive way to prioritize others.

To serve as fully as possible there is a certain amount of self‐maintenance that must take place. Boundaries must be established and maintained. Recreation and sabbaticals must be incorporated. Growth and learning have to take place.

All of these things are self‐serving. They require us to say no to others and yes to ourselves. At times, we wind up saying “me before you today because I want to be able to serve you tomorrow”.

But at the same time, all of these things flow from a mature understanding of “you before me” — putting our followers’ long‐term good above their short‐term desires. For an organization, a leader who says “us before me” builds strength. A leader who naively/hyperspiritually says “you before me” leads the organization to implosion (and likely to high leadership turnover).

Clearly, there is the potential for “us before me” to become a pretext for putting “me before you.” The antidote is to keep expanding our definition of “us”. Whenever we begin to suspect that our “us” is too comfortable, we need to redefine the group we are serving in a larger way, and continue to put “us before me.”

And so a big thanks to Dick Schroeder for giving me my new favorite phrase: “us before me”. It will probably be my favorite for at least a week. 😉

dr strangelove or how i learned to stop worrying and love the bomb movie black robe online download