Skip to content

Instantly share code, notes, and snippets.

@akinozgen
Last active November 17, 2018 08:28
Show Gist options
  • Save akinozgen/8c8040f9cf815abe901b0fcaaa7e717e to your computer and use it in GitHub Desktop.
Save akinozgen/8c8040f9cf815abe901b0fcaaa7e717e to your computer and use it in GitHub Desktop.
Best way to find php executable
<?php
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!');
else
$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