I need something like this in php:
If (!command_exists(\'makemiracle\')) {
print \'no miracles\';
return FALSE;
}
else {
// safely call the command kno
Platform independent solution:
function cmd_exists($command)
{
if (\strtolower(\substr(PHP_OS, 0, 3)) === 'win')
{
$fp = \popen("where $command", "r");
$result = \fgets($fp, 255);
$exists = ! \preg_match('#Could not find files#', $result);
\pclose($fp);
}
else # non-Windows
{
$fp = \popen("which $command", "r");
$result = \fgets($fp, 255);
$exists = ! empty($result);
\pclose($fp);
}
return $exists;
}