I needed this for scraping events, as DateTime::createFromFormat is so useful. The idea is to install php in a distinct folder (/opt/php5.3), and not install the Apache module.
First, download and decompress the source for PHP 5.3.
./configure --prefix=/opt/php5.3 \
--with-mysql=/usr/local/mysql --with-tidy=/usr/local --with-libxml-dir=/usr --with-xsl=/usr \
--with-openssl --with-zlib --with-bz2 --with-curl --with-gd --with-gettext --with-gmp \
--with-mysqli -with-pgsql --with-mssql \
--enable-exif --enable-ftp --enable-soap --enable-sqlite-utf8 --enable-mbstring --enable-dba \
--enable-debug \
--disable-xmlreader
(--disable-xmlreader is there because it doesn't compile cleanly on OS X.)
After running make and sudo make install, add /opt/php5.3/bin to $PATH in .bashrc.
To install additional modules, run phpize; ./configure; make; sudo make install;
from inside php5.3-source/ext/MODULE.
php.ini is in /opt/php5.3/lib
To install PEAR: curl http://pear.php.net/go-pear > go-pear.php && sudo php go-pear.php
To install PEAR/PECL modules, use sudo [pear|pecl] install MODULE.