Richard Davey Has a Blog

07 Nov 2005

I just noticed that another prominent member of the PHP community has started a blog. Richard Davey has been answering questions on various PHP mailing lists and forums for years, and now he has his own blog. Are you subscribed?

Note: The list of blogs I read is much more complete than the feed. Anyone know if this is a known del.icio.us bug?

One of his first entries is a response to a rather poor list of PHP tips. Richard counters many of the supposed performance tips that focus on trivial details such as single quotes versus double quotes. He also mentions the importance of readability. I think this is a point that is often lost, especially for developers who seek to impress others with the complexity of their code. Personally, I feel successful when my solution to a problem is unimpressive and painfully simple.

One thing that surprises me is that Richard seems to agree that concatenation is more readable than interpolation. Personally, I prefer interpolation:

  1.  
  2. $name = 'Chris'; 
  3. $location = 'New York'; 
  4.  
  5. echo "My name is $name, and I live in $location."; 
  6.  

I think concatenation is less clear:

  1.  
  2. $name = 'Chris'; 
  3. $location = 'New York'; 
  4.  
  5. echo 'My name is ' . $name . ', and I live in ' . $location . '.'; 
  6.  

You could argue that concatenation is clearer to PHP, but I try to focus on what's clearer to the developer. Which do you prefer?

Update: Richard says he usually prefers interpolation. I guess we agree on all points. :-)