Some PHP Code cannot get HOME environment variable.
getenv('HOME'); // OK
exec("env",$out);
print_r($out,1); // OK
exec("echo $HOME", $out);
print_r($out,1); // NG
It's because your string is in double quotes and PHP is substituting the value of the variable $HOME
. Try changing the string to use single quotes. I.e.
exec('echo $HOME', $out);
exec("export", $out); print_r($out,1);
to see which env vars are set. Note however, that using exec like you are doing won't work on Windows.