Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Best way to find php executable
function getPHPExecutable() {
$phpExecutable = file_exists('/usr/bin/php') ? '/usr/bin/php' : false;
if (!$phpExecutable) {
exec('which php', $phpExecutableRawPath);
if (!strpos($phpExecutableRawPath[0], '/php')) {
if (!strpos(PHP_BINARY, '/php'))
die('No PHP executable found!');
$phpExecutable = PHP_BINARY;
$phpExecutable = $phpExecutableRawPath[0];
return $phpExecutable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.