If you need to test old code that depends on PHP 5.2, you will probably need to compile it yourself. If it does not compile successfully on your platform, check out php52-backports.
I recently had to use php52-backports because Dreamhost upgraded Ubuntu. The
--with-mysqli options would not work even after using the patch, so I had to remove them.