From inside a PHP program I want to know the location of the binary executing it. Perl has $^X
for this purpose. Is there an equivalent in PHP?
This is so it can execute a child PHP process using itself (rather than hard code a path or assume "php" is correct).
UPDATE
Things I've tried and don't work:
$_SERVER['_']
looks like what I want from the command line but its actually from an environment variable set by the shell of the last executed program. When run from a web server this is the web server binary.which php
will not work because the PHP binary is not guaranteed to be the same one as is in the web server's PATH
.Thanks in advance.
The PHP_BINDIR constant gives you the directory where the php binary is