I simplehtmldom ki bu funciton sahip yararlanarak yapıyorum:
// get html dom form file
function file_get_html() {
$dom = new simple_html_dom;
$args = func_get_args();
$dom->load(call_user_func_array('file_get_contents', $args), true);
return $dom;
}
Ben bu yüzden gibi kullanabilirsiniz:
$html3 = file_get_html(urlencode(trim("$link")));
Bazen, bir URL sadece geçerli olmayabilir ve ben bu işlemek istiyorum. Ben denemek ve yakalamak kullanabilirsiniz düşündüm ama bir istisna değil beri bu amele değil, sadece böyle bir php uyarı verir:
[06-Aug-2010 19:59:42] PHP Warning: file_get_contents(http://new.mysite.com/ghs 1/) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/example/public_html/other/simple_html_dom.php on line 39
Hat 39 yukarıdaki kodu olduğunu.
Bir boolean döner gibi ben doğru bu hatayı işleyebilir nasıl, ben sadece bir ova if durumu kullanabilirsiniz, o görünmüyor.
Herhangi bir yardım için teşekkür ederiz
Update
Bu iyi bir çözüm var mı?
if(fopen(urlencode(trim("$next_url")), 'r')){
$html3 = file_get_html(urlencode(trim("$next_url")));
}else{
//do other stuff, error_logging
return false;
}