Steve's No Direction Home Page

My mule is sick and my horse is blind.

 















Subscribe to "Steve's No Direction Home Page" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 

 

  Friday, November 03, 2006


While reading up on the Zend Framework yesterday, I came across a sentence that blew my mind. (I'm perfectly willing to admit that that might not be saying much.)

A couple months ago, I spent the better part of a day trying to debug our outbound RSS feeds; there was whitespace -- usually a return, but sometimes several and sometimes a bunch of spaces as well -- at the top of the feeds. XML parsers were complaining, as is their habit. It took me a while to figure out what was going on -- one of us was using an editor that was in the habit of inserting returns after the ?> at the end of the PHP files. Since we have several hundred PHP files in the app, this took a while (and yes, I'm not grep-savvy enough to find them automatically). It was pretty annoying, and the problem happened a couple times before we got everyone set up correctly.

So yesterday I was reading a tutorial on Zend Framework, and came across this:

Note that we do not put in the ?> at the end of the file as it is not needed and leaving it out can prevent some hard-to-debug errors.

Wow! Now, the first thing I do when I create a new PHP file is to put in the opening and closing PHP tags. And if you're mixing PHP and HTML in the same file, it is, of course, essential that you close the PHP tags, or else the browser will choke on your PHP code, and you'll probably be telling users more than you want to.

On the other hand, and I've tested this today, if the file consists of only PHP, or it is in PHP at its end, you don't need the closing tag, and as Rob Allen said in that tutorial, and as I can attest, having it in there can cause some "hard-to-debug errors." It feels so, as Paul put it, untidy, and unsymmetrical, but it does work, and if I can break the question-mark-greater-than-sign habit, I'll stop using it.


1:47:03 PM    comment []

This is a wonderful album of shots from the Space Telescope; I'm sure I've linked to it before. It's very exciting news that a NASA that has really seemed to have lost its way over the past few years has decided to repair the telescope instead of letting it languish. They realize what a PR disaster that would be -- everyone loves the Hubble scope, but nobody even knows why the Space Station is there.


9:47:57 AM    comment []


Click here to visit the Radio UserLand website. © Copyright 2006 Steve Michel.
Last update: 12/1/2006; 4:02:07 PM.

November 2006
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Oct   Dec