Web development

All about everyone's favorite pseudo-platform, the World Wide Web.

Go PHP 5, Go!

Submitted by Larry on 5 July 2007 - 1:09am

Go PHP 5!

"Never believe that a few caring people can't change the world. For, indeed, that's all who ever have." --Margaret Mead

A while back, various people were lamenting the state of PHP 5 adoption, myself included. What to do about it? How to get hosts to let programmers leverage the added functionality that PHP 5 offers? How can we do that without cutting off 80% of our user base?

The solution a few people suggested was team work. If all PHP projects stopped supporting PHP 4 and made the jump to PHP 5 at the same time, none of them is penalized in the market for being "first" and web hosts will have a clear business case to upgrade their systems to PHP 5. We can then all start offering faster, cleaner, more powerful, more secure web software.

But how does one get all PHP projects together to agree on something like that? Actually, it's fairly simple. You ask them.

Web 2.0 in Web 2.0

Submitted by Larry on 13 February 2007 - 11:11pm

I normally don't post random "hey this is cool" posts, but this one really is that cool. The second video isn't all that great, giving more of a business talk, but the first one is slick, cool, insightful, and elegant. (About 5 minutes each.) Web 2.0 explained using Web 2.0. Nice!

Sweet 16

Submitted by Larry on 14 January 2007 - 5:41pm

When is Unicode not Unicode? When it's UTF-16 instead of UTF-8. Both are properly Unicode character sets, but for reasons that escape me they are not fully compatible. In today's installment of "Fix Microsoft's bugs", we'll look at how to deal with that little problem.

MVC vs. PAC

Submitted by Larry on 31 December 2006 - 4:42pm

One of the most common mistakes I see people make when talking about web architecture is with regards to MVC. Generally it comes down to a statement such as this:

It's a web app, so we have to use MVC. That way we separate the logic and presentation, which means keeping PHP out of our display layer. All the important projects do it that way.

Of course, such a statement is false. It demonstrates a lack of understanding about MVC, about web applications, about "important projects", and about software architecture in general. Let's try to clarify, with a little help from Wikipedia.

PHP Group By with Arrays

Submitted by Larry on 2 December 2006 - 4:57pm

By far the most common idiom when using SQL from a web application (PHP or otherwise) is simply listing records. The standard logic looks something like this (give or take real templating):

<?php
$result
= mysql_query("SELECT tid, name, size, color FROM things ORDER BY name, size");
print
"<table>\n";
print
"<tr><th>Name</th> <th>Size</th> <th>Color</th></tr>\n";
while (
$record = mysql_fetch_object($result)) {
  print
"<tr>\n";
  print
"<td><a href='viewthing.php?tid={$record->tid}'>{$record->name}</a></td>\n";
  print
"<td>{$record->size}</td>\n";
  print
"<td>{$record->color}</td>\n";
  print
"</tr>\n";
}
print
"</table>\n";
?>

That's all well and good, but in practice can be quite limiting. Why? Because you can't then group records, that is, display not one but several tables, one for each color. SQL, of course, offers a GROUP BY clause. That doesn't do what we want, however. GROUP BY is an aggregate clause, and is used for creating totals and summaries of records. We want to cluster records by a field that is not the ordering field, or a value that is calculated off of the record itself.

I've generally used two different methods for PHP-side grouping, one of them much cleaner and more flexible at the cost of a little performance.

Stupid quotes

Submitted by Larry on 24 November 2006 - 5:50pm

A perennial problem for anyone in IT is the infernal beast known as "smart quotes". Smart quotes, also known as "curly quotes", refers to the angled apostrophe and quotation characters that are often used in print but are not found on any conventional keyboard. There's a number of problems with them. First of all, most people don't realize what they are. Then most people don't understand how they work. And finally, Microsoft broke them.