【问题标题】:php search for work on specific urlphp 搜索特定 url 上的工作
【发布时间】: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


【解决方案1】:

$command1 变量包含exec 函数调用(向您发送电子邮件)的结果。

如果您想在页面内容中找到文本时发送邮件 - 在这种情况下,您应该调用exec函数only

$text1 = file_get_contents('http://example.com/page');
$intext1 = strpos($text1, 'tvshenja1') !== false; // note !==, not !=

if ($intext1) {
    echo 'do nothing';
} else {
    echo exec("mail -s 'title' info@example.com  <<< 'message'");
}

【讨论】:

  • 我想你忘了;
  • 抱歉,第一次回显后错过了;。检查更新并重试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-04-22
  • 2018-10-06
  • 2013-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多