Errors checking and opening a URL using PHP
- by Jean
Hello
Here is one script with out any errors
$url="http://yahoo.com";
$file1 = fopen($url, "r");
$content = file_get_contents($url);
$t_beg = explode('<title>',$content);
$t_end = explode('</title>',$t_beg[1]);
echo $t_end[0];
And here is the same script using a look to check multiple urls and getting errors
for ($j=1;$j<=$i;$j++) {
if ($x[$j]!=''){
$t_u = "http:".$x[$j];
$file2 = fopen($t_u, "r");
$content2 = file_get_contents($t_u);
$t_beg = explode('<title>',$content);
$t_end = explode('</title>',$t_beg[1]);
echo $t_end[0];
}
}
The error is Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in g:/
What exactly is wrong here?