在Linux / Mac OS上,请尝试以下操作:
function command_exist($cmd) { $return = shell_exec(sprintf("which %s", escapeshellarg($cmd))); return !empty($return);}然后在代码中使用它:
if (!command_exist('makemiracle')) { print 'no miracles';} else { shell_exec('makemiracle');}更新: @ camilo-martin建议,您可以简单地使用:
if (`which makemiracle`) { shell_exec('makemiracle');}


