How to get the full path to php interpreter / binary without shell access

大城市里の小女人 提交于 2019-11-29 05:57:09

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

parera riddle

Linux users can try the whereis command.

I had this situation with a PHP IDE.

whereis php

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

its not common for a host to give root access to its users. Most probably, you can't access anything below /var/www

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!