I'm trying to find a way to handle any 4xx and 5xx error status codes throw by a url like Apache 404 error. I'd like to execute the contents of the if statement only if there are no error status codes thrown by the server.
Using the following if statement it seems that even with the hosted content not being found and throwing an Apache 404 error its still running the contents of the if statement.
if (@fopen('http://example','r')){
use resource
}
else{
use other resources
}
is there a better way to ensure the url is available before running it?
Edit: i can't use curl in this instance.
thanks