The answer to the question posed is WURFL [wurfl.sourceforge.net], which is a fairly simple (but large) XML flatfile database that has been compiled by an Italian chap who works for OpenWave.
With a couple of lookup utilities, this database will match the user-agent of your phone to a set of capabilities. This means that if you have a phone that can handle WML 1.1, but not GIF files, you can feed it 1.1 pages with WBMP files.
It took me a while to get it going. Like so much of this kind of thing, documentation is a bit...sparse, but it's fairly easy to implement.
The developers prefer using Java to implement it, but there is a PHP [wurfl.sourceforge.net] implementation of it, and that's what I got going.
The biggest problem is the cache. It gets pretty big, quickly. At that size, I'm not so sure it really buys you much, as it will take PHP as long to look something up in the cache as it will to load the XML file.
It also exhausted the PHP memory allocation on my server.
I'm currently not using the cache, but there's a lot of stuff on it, written by the chap who did the PHP implementation. I'll have to see if I can make it work. He swears by it.
In any case, if you want to identify your device, WURFL seems to be the way to do it. It has achieved a great deal of acceptance, and appears regularly in scholarly writings on the subject.
[edited by: encyclo at 7:06 pm (utc) on April 15, 2007]
[edit reason] thread splice and tidying up [/edit]