2016-08-15 89 views
-3

我正在使用file_get_contents();网页:检查网页是否含有文本

$file = file_get_contents('http://example.com'); 

如何检查网页是否含有文本“你好”和“再见”

+1

可能[检查字符串是否包含特定单词?](http://stackoverflow.com/questions/4366730/check-if-string-contains-specific-words) – piedar

回答

0
$file = file_get_contents('http://example.com'); 
if (strpos($file, 'hello') !== false) 
{ 
    echo "Exist.."; 
} 
+0

对不起,请检查以确定您是否在那里或再见? –

1
$file = file_get_contents('http://example.com'); 
$exists = (strpos($file, 'hello') !== false) || (strpos($file, 'bye') !== false); 
if ($exists !== false) { 
    print 'Found'; 
} 
+0

对不起,这是否检查,看看你好或者再见? –

+0

是的,它确实检查,看看你好,是否在那里或再见 –

+0

不,我是指哪一个检查 –