PHP 5 configuration and the Law of Computer Frustration

I've long subscribed to the following maxim, particularly in reference to high tech:

"The more frustrating the problem, the more simple the solution."

I doubt that it was my noodle that thunk this one up, but I've experienced its effect time after time.

I've uttered the phrase on more than a few occasions in any of my semi-colon/curly-brace classes. Take my web applications with PHP and MySQL course for example: omitted semicolons, missing curly braces, misspelled variable names, and -- my personal favourite -- blank spaces following a closing ?> tag in an included PHP file, are the sort of things that can completely vapour-lock a beginning programmer. And the frustration of staring hopelessly at such a problem for a good half-hour doesn't improve after I show up with a merry whistle and point out the missing closing parenthesis in the for statement. (I then suggest "aaaaaargh" as the appropriate vocalization of that specific emotion.)

I'm not immune from the law's effects, but my frustrations are more frequently due to configuration file settings.

Just this morning I was installing the whole WAMP stack on my freshly nuked-and-paved PC. As the first test of PHP (version 5 this time), I whipped up the same file that everybody does, containing: <?phpinfo()?>

Expecting the pleasant purple PHP page in the browser, I got bupkes. View Source showed the un-interpreted PHP source code, so I immediately jumped to the very wrong conclusion that the PHP Apache module wasn't PHP-ifying properly. Twenty minutes of tests couldn't confirm that PHP wasn't working.

As a penultimate recourse -- the very last recourse involving actual reading of manuals -- I turned to the php.ini configuration file. Somewhere near the top was this innocuous line:

short_open_tag = Off

Apparently PHP5 expects the full <?php open tag as a default. (The language lawyer in me says "just as it should be", but the longtime PHP contractor in me replies "Oh, you must be joking.") A quick change to On, an Apache restart, and it was purple goodness as far as the eye can scroll.

Two seconds to fix a thirty-minute problem: law upheld.

Comments