Errors checking and opening a URL using PHP

Posted by Jean on Stack Overflow See other posts from Stack Overflow or by Jean
Published on 2010-03-28T08:47:10Z Indexed on 2010/03/28 8:53 UTC
Read the original article Hit count: 243

Filed under:

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?

© Stack Overflow or respective owner

Related posts about php