Archive for the ‘PHP’ Category

Time for strftime

Wednesday, May 16th, 2007

Big Ben clockface

The strftime function is a common way for programmers to convert a computer time into a human-readable string. You can pronounce it “string-f-time”, “string-from-time”, or “string-format-time”. While Ruby and PHP each have their own implementation, the function is actually part of the Unix open spec. That’s great news for developers because it means that we can reuse the formatting techniques in any language. I’ve also found that the Ruby/Rails docs are a little lacking and you might not have known that there were more options available. Since it’s not just for Ruby, we don’t have to rely on them as our sole source of information.

Keep reading and I’ll show you how to use strftime, give you a full list of format codes (downloadable even), and demonstrate a useful helper function for working around one of the quirks of strftime.

(more…)

PHP/Oracle Manual

Tuesday, May 15th, 2007

Are you working with PHP and Oracle? Oracle has just released an updated version (v1.4) of the Underground PHP and Oracle Manual. It’s downloadable as a free PDF.

How to Kill PHP 4?

Saturday, May 12th, 2007

That’s the question being discussed among some prominent Drupal and WordPress developers right now. You see, the problem isn’t that they don’t love PHP, Drupal and WordPress are two of the most popular PHP applications. And both of them use PHP 4. (Null is Love is running WordPress with PHP 4.3)

Drupal and WordPress logos

The problem, they say, is that web hosting companies are reluctant to switch to new-and-improved, object-oriented PHP 5. (PHP 5 has only 17% adoption after almost 3 years.) Therefore the developers can’t roll out versions of their apps which require PHP 5. And since major applications don’t require it, the web hosting companies don’t feel any pressure to switch, especially since both PHP 4 and 5 are being supported by bug and security fixes. For them, software upgrades equals support headaches which equals time and money, so they need a compelling motivation. It’s become a chicken-and-egg problem (a.k.a. deadlock) and these PHP developers are looking for a way out.

So what to do?

(more…)

Zebra Striping

Wednesday, May 9th, 2007

Let’s kick off with something easy—zebra stripes! What’s that, you ask? It’s what we call it when rows alternate between two colors, usually light and dark. Here’s an example:

Zebra Stripe Example

Contrasting row colors make it much easier to read. The reader’s eye can easily follow along the row to associate the state with the dollar amount. It’s a useful technique whenever you are outputing reports or lists of data. I’ll demonstrate three ways to do it.

(more…)