php - Preventing php_network_getaddresses: getaddrinfo failed: -
php - Preventing php_network_getaddresses: getaddrinfo failed: -
i trying phone call url php check if exists , reachable.
my initial code was
fopen('http://'.$this -> url, 'r');
but throws next errors every time url unreachable:
fopen(http://dwzegdzgwedzgew.com): failed open stream: php_network_getaddresses: getaddrinfo failed php_network_getaddresses: getaddrinfo failed:
the error operator (@) ignored in case error isn't thrown fopen while resolving asdress. thought should it:
@fopen(@'http://'.$this -> url, 'r');
but goes on throwing error.
is there non-error-throwing possibility check if url exists within php before opening it?
what error message $ressource = @fopen('http://' . $this->url, 'r');
?
<?php $urls = array('kihgkighuhgkig.li', 'google.com', 'adsfafdf.fr'); foreach ($urls $url) { if (gethostbyname($url) != $url) { $ressource = fopen('http://' . $url, 'r'); var_dump($url, $ressource); } }
the output :
$> php test.php string(10) "google.com" resource(6) of type (stream)
php fopen getaddrinfo
Comments
Post a Comment