From the command line, I can get the home directory like this:
~/
How can I get the home directory inside my PHP CLI script?
This is the method i used in a recent project:
exec('echo $HOME')
I saved it into my object by doing this:
$this->write_Path = exec('echo $HOME');
But you could really save it any way you want and use it anyway you see fit.