How can I get the path of the PHP binary from PHP?

Wiliam picture Wiliam · Oct 8, 2010 · Viewed 47.2k times · Source

How can I get the binary path of php from PHP?

I saw it in phpinfo(), but I need another method that gets it in Linux and Windows systems.

Answer

codaddict picture codaddict · Oct 8, 2010

You can use:

$_SERVER['_']

Also, the predefined constant PHP_BINDIR gives the directory where the PHP executable is found.

Sample on CodePad and Ideone.

It looks like, for security reasons, $_SERVER values are not exposed.