How can I know when I use php to show the status of the opposite server 502404500?

the counterparty uses the nginx ubuntu server

I use curl to communicate with him
I would like to say how to make a php interview
after entering this interview, I can find out the current server status of the counterparty
but how can I write this code if the counterparty gives me a reply of 502 or other errors
?

call his primary domain name with curl?
or is there any other way?

Mar.04,2021

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

for more details, please see http://php.net/manual/zh/func.

.
Menu