Installing PHP 5.3 and 5.4 is really easy with HomeBrew. PHP is included with Snow Leopard and Lion, but isn’t the latest version. If you want to run a newer version of PHP, such as PHP 5.4, you can install it through HomeBrew.
Here’s a site with good instructions on installing PHP via HomeBrew.
The only change that I had to make was with the brew install command since there are now two versions supported (5.3 and 5.4).
brew install php53 --with-mysql --with-intl
brew install php54 --with-mysql --with-intl