How to check if a shell command exists from PHP

后端 未结 7 1005
孤街浪徒
孤街浪徒 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:22

    No, there are not.

    Even when having direct access to a shell, you do not know if a command exists. There a some tricks like wheris or find / -name yourcommand but that not a 100% guarantee that you can execute the command.

提交回复
热议问题