php 搜索关于特定 url 的工作

php search for work on specific url

我想在示例中搜索一个词。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 函数 只有 在这种情况下:

$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'");
}