command line - How to get directory where PHP script was called from -


i have php script in directory. when call command line, getcwd(), __dir__ , exec("pwd") return directory of script itself, not pwd.

e.g. calling /some/place/test.php /tmp:

echo(getcwd());        // prints /some/place  echo(exec("pwd"));     // prints /some/place  echo(__dir__);         // prints /some/place  echo($_server["pwd"]); // prints /tmp 

$_server["pwd"] has value need, it's not mentioned in docs http://php.net/manual/en/reserved.variables.server.php

almost hit "post question" , guessed check command line parameters. :-)

$ php -h ...   -c               not chdir script's directory ...