Find it via Bash:
echo $HOME
You can use this in other languages. For instace, PHP:
$home = exec('echo $HOME');
Make sure you use the single quotes rather than the double quotes. If you use double quotes, PHP will think that $HOME is a defined variable rather than a string.