Answer the question
In order to leave comments, you need to log in
How to catch 404 when requesting api?
Hello. I have a site that knocks on api to another site, I get a response from it with the help, file_get_contents
but what if the server does not respond? How can I catch 404 and then perform some actions?
Answer the question
In order to leave comments, you need to log in
function get_contents() {
file_get_contents("http://example.com");
var_dump($http_response_header);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question