The actual name of the constant is CURLINFO_HTTP_CODE (not CURLINFO_RESPONSE_CODE , which is for libcurl ). Although the title contains HTTP, you can also get FTP response codes:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'ftp://user: pass@host.com '); curl_exec($ch); $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo $response_code; // outputs 226, which means 'Closing data connection'
source share