Archive for March, 2010

Fix your tables: how to stop cells from expanding out of control

Tuesday, March 23rd, 2010

HTML tables receive a bit of a bad rap thanks to years of abuse in web design, however in reality they’re semantic as the next element. They do have their quirks though, one common problem is that instead of aligning themselves like the rigid blocks we’re used to they tend to be a bit more fluid – expanding and contracting to fit their content.

This useful behaviour can become frustrating when a carefully laid-out table encounters abnormal input and suddenly decides to stop paying attention to the cell widths we’ve specified. Luckily there is a simple solution to this. All the major browsers implement an alternative fixed table layout which is specified through the appropriately named table-layout CSS property. (more…)

Digging deeper into PHP’s static scoping

Friday, March 19th, 2010

Redditor troelskn made an interesting observation about my recent blog post about Singletons, pointing out that static variables defined within a method behave completely differently to regular static properties. I use static method variables often but still found this behaviour surprising. I decided this was a good opportunity to find out exactly how static methods, properties and variables work in PHP. (more…)

Singletons: What can they teach us about PHP?

Wednesday, March 10th, 2010

Why would I be showing you how implement singletons in PHP? Don’t I know that the singleton pattern suffers from obvious shortcomings? Of course I do, but I have an ulterior motive. Singletons are a simple way to show off some of the features of PHP you probably don’t get to see and use too often. Now we’ve got that covered let’s see some code. If you haven’t seen a Singleton before the premise is simple: there should only ever be one instance of our class. (more…)