【发布时间】:2016-08-15 16:15:41
【问题描述】:
我正在获取一个使用 file_get_contents(); 的网页:
$file = file_get_contents('http://example.com');
如何检查网页是否包含文本“你好”或“再见”
【问题讨论】:
标签: php file-get-contents
我正在获取一个使用 file_get_contents(); 的网页:
$file = file_get_contents('http://example.com');
如何检查网页是否包含文本“你好”或“再见”
【问题讨论】:
标签: php file-get-contents
$file = file_get_contents('http://example.com');
$exists = (strpos($file, 'hello') !== false) || (strpos($file, 'bye') !== false);
if ($exists !== false) {
print 'Found';
}
【讨论】:
Found 将被打印
$file = file_get_contents('http://example.com');
if (strpos($file, 'hello') !== false)
{
echo "Exist..";
}
【讨论】: