php搜索特定url上的工作

php搜索特定url上的工作,php,exec,shell-exec,Php,Exec,Shell Exec,我想在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') !== f

我想在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;

然后它向我显示消息单词不存在,但当我尝试使用$command1时,在这两种情况下,它都会将消息发送到我的邮件。
$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'");
}
$text1=文件获取内容('http://example.com/page');
$intext1=strpos($text1,'tvshenja1')!=假;//注意!==,不是=
如果($intext1){
回声“什么也不做”;
}否则{

echo exec(“邮件-标题”info@example.com
$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'");
}