How can I get the full path to php interpreter from a php script (no command line access).
What I need to do is:
$foo = \"/usr/bin/php\";
echo $foo;
Linux users can try the whereis
command.
I had this situation with a PHP IDE.
whereis php
You can find the PHP binary path with this constant:
PHP_BINDIR
As of PHP 5.4, you can get the path to the executable actually running currently with this constant:
PHP_BINARY
http://php.net/manual/en/reserved.constants.php
its not common for a host to give root access to its users. Most probably, you can't access anything below /var/www
On Windows I would suggest the following snippet:
<?php
$pid = getmypid();
$output = shell_exec(sprintf('tasklist /nh /fo csv /fi "PID eq %d"', $pid));
$processInfo = explode(',', $output);
echo PHP_BINDIR . DIRECTORY_SEPARATOR . trim($processInfo[0], '"');
On unix the shell command should probably make use of ps