How to check if a shell command exists from PHP

后端 未结 7 973
孤街浪徒
孤街浪徒 2020-12-25 11:07

I need something like this in php:

If (!command_exists(\'makemiracle\')) {
  print \'no miracles\';
  return FALSE;
}
else {
  // safely call the command kno         


        
7条回答
  •  礼貌的吻别
    2020-12-25 11:30

    You could use is_executable to check whether it is executable, but you need to know the path of the command, which you could use which command to get it.

提交回复
热议问题