How to get the home directory from a PHP CLI script?

前端 未结 13 1065
生来不讨喜
生来不讨喜 2020-12-08 03:45

From the command line, I can get the home directory like this:

~/

How can I get the home directory inside my PHP CLI script?



        
13条回答
  •  攒了一身酷
    2020-12-08 04:35

    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.

提交回复
热议问题