On the Changeblog there's a recent post showing you how to get both PHP 5.2 and PHP 5.3 installed on the same machine for your development or testing needs (they target it at Durpal users, but it applies for any PHP app).
Although Drupals 7+ run smoothly on PHP 5.3, Drupal 6 still feels much better with PHP 5.2. Even though D6 core is compatible with PHP 5.3 for quite some time now, a lot of contributes modules still get nasty hiccup when asked to run on the newer version. Therefore developing for both D7 and D6 at the same time becomes much less painful when running both versions of PHP in parallel.
They help you get things compiled from source with the command line input you'll need to get it up and working. Also included is a handy section about possible errors you could get during the configure as well as the packages you might need to install to fix them. Also included are the updates you'll need to make to your configuration files to get things up and running.