I am working on getting the header response codes for a list of urls. I need the output to be like HTTP/1.1 200 OK
etc.
Using cURL - I used this command curl -s -I https://www.pnc.com | grep HTTP
(or) curl -I https://www.pnc.com 2>/dev/null | head -n 1
. And, I get the output as HTTP/1.1 200 OK
.
Using PHP - I used get_headers() command to do the same in PHP. And I'm getting the output as HTTP/1.1 301 Moved Permanently
.
This is the code that I used.
$line = "https://www.pnc.com";
$myheader = get_headers($line,1);
echo "$myheader[0]";
After running this, I get the output as HTTP/1.1 301 Moved Permanently
. Can someone give any suggestions?