I need something like this in php:
If (!command_exists(\'makemiracle\')) {
print \'no miracles\';
return FALSE;
}
else {
// safely call the command kno
Based on @xdazz answer, works on Windows and Linux. Should also work on MacOSX too, since it's unix.
function is_windows() {
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
function command_exists($command) {
$test = is_windows() ? "where" : "which";
return is_executable(trim(shell_exec("$test $command")));
}