- substr: documentation ( source)
- get_headers: documentation ( source)
- var_dump: documentation ( source)
<?php
function get_http_response_code($url) {
$headers = get_headers($url);
// echo substr($headers[0], 9, 3);
$headers = substr($headers[0], 9, 3);
// $headers = "bla"; // setting headers to bla works then $b = bla;
var_dump($headers); //returns string 3 (404)
return $headers;
}
$b = get_http_response_code('http://noneexisting.com/blabla.html');
var_dump($b);