Mac OSX come with pre-installed php , but many time you will find that its old version or you want to upgrade for your project specific needs then use this guide to download and install most up to date php in your mac OSX
<p>
<b>Test your php installation </b><br />open terminal and type
</p>
<pre class="codesBash">php --version</pre>
<p>
you will see something like this
</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/--ymSNy13Po0/UEoPsHxrHWI/AAAAAAAAGqM/SyiHs_J1aXg/s1600/php+--version.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="http://2.bp.blogspot.com/--ymSNy13Po0/UEoPsHxrHWI/AAAAAAAAGqM/SyiHs_J1aXg/s640/php+--version.png" width="640" /></a>
</div>
<p>
<a name="more"></a>
</p>
<div style="text-align: center;">
</div>
<p>
or if you will check with phpinfo function you will see your php installation info
</p>
<pre><?php phpinfo() ??></pre>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;">
<tr>
<td style="text-align: center;">
<a href="http://3.bp.blogspot.com/-WimQ0BhNzRY/UEoP17d-F5I/AAAAAAAAGqU/dsPWw6SSTkY/s1600/phpinfo.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="517" src="http://3.bp.blogspot.com/-WimQ0BhNzRY/UEoP17d-F5I/AAAAAAAAGqU/dsPWw6SSTkY/s640/phpinfo.jpg" width="640" /></a>
</td>
</tr>
<tr>
<td class="tr-caption" style="text-align: center;">
phpinfo
</td>
</tr>
</table>
<p>
Tested on mac OSX snow leopard and mountain lion ( intel )
</p>
<p>
<br class="Apple-interchange-newline" /><b>Prerequisite knowledge and software for compiling php : </b>
</p>
<ul>
<li>
Basic Unix skills (being able to operate “make” and a C compiler)
</li>
<li>
An ANSI C compiler
</li>
<li>
A web server
</li>
<li>
Any module specific components (such as GD, PDF libs, etc.)
</li>
</ul>
<p>
<span style="color: #cc0000; font-size: large;">Install<b> XCODE</b> and <b>XCODE command lines tools</b> before start compiling</span>
</p>
<p>
</p>
<div style="text-align: center;">
<a class="download-button" href="https://github.com/kennethreitz/osx-gcc-installer" target="_blank">Download </a>
</div>
<div style="text-align: center;">
</p>
<div style="text-align: left;">
Steps :
</div>
<div style="text-align: left;">
1: Download PHP source codes
</div>
<div style="text-align: left;">
2 : extract source code
</div>
<div style="text-align: left;">
3 : open terminal and change directory to extracted folder
</div>
<div style="text-align: left;">
4: complie with</p>
<div>
<span style="background-color: white;"><br /></span></p>
<h3 style="text-align: left;">
<span style="background-color: white;">install dependencies first </span>
</h3>
<p>
</p>
<div style="text-align: left;">
</div>
<ul style="text-align: left;">
<li>
brew install libjpeg
</li>
<li>
brew install pcre
</li>
<li>
brew install libxml2
</li>
<li>
brew install mcrypt
</li>
<li>
brew install openssl
</li>
<li>
brew install libpng
</li>
</ul>
<p>
now customise and configure php installation according to your need
</p>
</div>
<pre class="codesBash">./configure <br />--prefix=/usr <br />--mandir=/usr/share/man <br />--infodir=/usr/share/info <br />--sysconfdir=/private/etc <br />--with-apxs2=/usr/sbin/apxs <br />--enable-cli <br />--with-config-file-path=/etc <br />--with-libxml-dir=/usr <br />--with-openssl=/usr <br />--with-kerberos=/usr <br />--with-zlib=/usr <br />--enable-bcmath <br />--with-bz2=/usr <br />--enable-calendar <br />--with-curl=/usr <br />--enable-dba <br />--enable-exif <br />--enable-ftp <br />--with-gd <br />--enable-gd-native-ttf <br />--with-icu-dir=/usr <br />--with-iodbc=/usr <br />--with-ldap=/usr <br />--with-ldap-sasl=/usr <br />--with-libedit=/usr <br />--enable-mbstring <br />--enable-mbregex <br />--with-mysql=mysqlnd <br />--with-mysqli=mysqlnd <br />--without-pear <br />--with-pdo-mysql=mysqlnd <br />--with-mysql-sock=/var/mysql/mysql.sock <br />--with-readline=/usr <br />--enable-shmop <br />--with-snmp=/usr <br />--enable-soap <br />--enable-sockets <br />--enable-sysvmsg <br />--enable-sysvsem <br />--enable-sysvshm <br />--with-tidy <br />--enable-wddx <br />--with-xmlrpc <br />--with-iconv-dir=/usr <br />--with-xsl=/usr <br />--enable-zip <br />--with-imap=/usr/local/imap-2007 <br />--with-kerberos <br />--with-imap-ssl <br />--enable-intl <br />--with-pcre-regex <br />--with-pgsql=/usr <br />--with-pdo-pgsql=/usr <br />--with-freetype-dir=/usr/X11 <br />--with-jpeg-dir=/usr <br />--with-png-dir=/usr/X11</pre>
<pre class="codesBash"><br /></pre>
<p>
Now test and install if all is good
</p>
<ul style="text-align: left;">
<li>
<span style="font-family: inherit;">make test </span>
</li>
<li>
<span style="font-family: inherit;">sudo make install<br /></span>
</li>
</ul>
</div>
</div>
<p>
after installation again type
</p>
<pre class="codesBash">php --version</pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-gX__4zx8G8s/UEoXFtygkWI/AAAAAAAAGrk/JcDN4wFrCEc/s1600/Screen+Shot+2012-09-07+at+9.08.55+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="http://2.bp.blogspot.com/-gX__4zx8G8s/UEoXFtygkWI/AAAAAAAAGrk/JcDN4wFrCEc/s400/Screen+Shot+2012-09-07+at+9.08.55+PM.png" width="400" /></a>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="background-color: rgba(138, 138, 138, 0.5);">
if above method dont work for you use<br /> <a href="http://php-osx.liip.ch/">http://php-osx.liip.ch/</a></p>
</div>
<p>
Settting up php <a href="http://www.computersnyou.com/2012/06/setting-up-apache-and-php-with-mysql-in.html" target="_blank">mysql and apache on mac osx see this guide >> </a></div>
<div>
</div></div>