Last active
November 17, 2018 08:28
-
-
Save akinozgen/8c8040f9cf815abe901b0fcaaa7e717e to your computer and use it in GitHub Desktop.
Best way to find php executable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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