<?php
error_reporting(0);
$ctx = stream_context_create(array('http'=>
array(
'timeout' => 5,
)
));
$handle = fopen("ist.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
$check = file_get_contents($line, false, $ctx);
if ($check == 'hi.') {
echo $line;
echo 'yay';
} else {
echo 'ney';
echo $line;
}
}
} else {
echo 'error reading file';
}
fclose($handle);
?>
当我只做了 1 个网址时,它就有效了。
基本上它所做的是打印出 neyhttp://mysite/hi.txt
不,该行没有任何空格或任何东西。
File_get_contents
给出了页面的来源。要检查内容使用情况:
if (stripos(strtolower($check), 'hi.') !== false) {
}