Hi,
download the sources from www.php.net.
Read the documentation about compiling and installing php.
In order to successfully compile php on Solaris you should install some important gnu tools like make, gcc and so on. You can download those packages on www.sunfreeware.com as Solaris packages.
Normally Solaris boots up to the X environment automatically if there is a supported graphics card installed.
You can try to enable the CDE with:
/usr/dt/bin/dtlogin -e (this enables the CDE desktop)
and reboot afterwards
reboot
It should then boot up to the CDE. You might need to wait a few seconds or minutes after rebooting, do not press a key while the system is booting otherwise it would take you to a command line login.