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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -