Install here:
http://www.entropy.ch/software/macosx/php/
To use it from the command line you need to add it to your .bash_profile and then close your terminal and re-open it.
E.g echo ‘export PATH=/usr/local/php5/bin:$PATH’ >> ~/.bash_profile
Another handy page is the MySQL on Leopard also by Marc Liyanage:
http://www.entropy.ch/software/macosx/mysql/