apache - PHP URL Error Handing -


i'm trying find way handle 4xx , 5xx error status codes throw url apache 404 error. i'd execute contents of if statement if there no error status codes thrown server.

using following if statement seems hosted content not being found , throwing apache 404 error still running contents of if statement.

if (@fopen('http://example','r')){             use resource } else{ use other resources } 

is there better way ensure url available before running it?

edit: can't use curl in instance.

thanks

 $headers = get_headers($url, 1);   if ($headers[0] == 'http/1.1 200 ok') {//no error status codes thrown server    $data = file_get_contents($url);    //do   } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -