【发布时间】:2016-12-02 00:16:49
【问题描述】:
我想在 example.com/page 上搜索一个词,如果该词存在则什么也不做,如果该词不存在则通过 shell_exec 给我发邮件
$command1 = exec("mail -s 'title' info@example.com <<< 'message'");
$text1 = file_get_contents('http://example.com/page');
$intext1 = strpos($text1, 'tvshenja1') !== false; // note !==, not !=
echo $intext1 ? 'do nothing' : $command1;
我使用此代码,但无论结果如何(存在或不存在)它都会向我发送邮件
如果我这样尝试
echo $intext1 ? 'do nothing' : 'word dont exist';
然后它显示消息字不存在,但是当我尝试使用 $command1 时,在这两种情况下它都会向我的邮件发送消息
【问题讨论】:
-
$command1变量包含exec函数调用(向您发送电子邮件)的结果。 只有如果你找到了文本,你应该运行exec命令。 -
你能用正确的代码回答吗
标签: php exec shell-exec