मैं URL का उपयोग करने के लिए file_get_contents() का उपयोग कर रहा हूं।file_get_contents जब url मौजूद नहीं है
file_get_contents('http://somenotrealurl.com/notrealpage');
यदि यूआरएल वास्तविक नहीं है, तो यह त्रुटि संदेश लौटाता है। मैं इसे गलती से गलती से कैसे प्राप्त कर सकता हूं ताकि मुझे पता चले कि पृष्ठ मौजूद नहीं है और इस त्रुटि संदेश को प्रदर्शित किए बिना तदनुसार कार्य करता है?
file_get_contents('http://somenotrealurl.com/notrealpage')
[function.file-get-contents]:
failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
in myphppage.php on line 3
Zend में उदाहरण के लिए आप कह सकते हैं: if ($request->isSuccessful())
$client = New Zend_Http_Client();
$client->setUri('http://someurl.com/somepage');
$request = $client->request();
if ($request->isSuccessful()) {
//do stuff with the result
}
धारा संदर्भ का उपयोग करके देखें: http://stackoverflow.com/questions/21800276/is-it-possible-to-get-404-page-content-using-fopen-in-php, file_get_contents fopen का उपयोग करता है हुड के नीचे। – rsk82