There are many ways to get the latest PHP version running on your mac,
but so far the one that seemed the least complicated is to use phpbrew
Start here: https://github.com/phpbrew/phpbrew
From there, there are instructions for getting PHP installed. It's also used as a version switcher, which can be useful for managing multiple projects with different version requirements.
I noticed, the build failed because of a missing component called "libmcrypt". To fix that I just installed that with homebrew:
$ brew install libmcrypt
Once you have that all set up properly, you can install the specific version of PHP you want:
$ phpbrew install 5.6.4 +default
Then use that version:
$ phpbrew switch php-5.6.4
You can check to make sure you're on the correct version:
php --version