PHP How To Find HTTP Status Code of Any Website Tutorial

Table of Contents

Share this Article
Reading Time: 2 minutes
326 Views

Inside this article we will see the concept i.e PHP How To Find HTTP Status code of any website. Article contains the classified information about Finding HTTP Status code of any website in PHP. There are several HTTP status code depends on the response of the website hosted server.

An HTTP status code is a server response to a browser’s request. When you visit a website, your browser sends a request to the site’s server, and the server then responds to the browser’s request with a three-digit code: the HTTP status code.

HTTP Status codes are – 200, 403, 404, 500, etc.

Learn More –

Let’s get started.

Application Programming

Create a file named as index.php. Write this code into it.

<?php

function get_response_code($url)
{
    @file_get_contents($url);
    list($version, $status, $text) = explode(' ', $http_response_header[0], 3);

    return $status;
}

echo get_response_code('https://www.yourwebsite.com/');

According to the response of website’s hosted server, we have these status codes –

We hope this article helped you to learn PHP How To Find HTTP Status Code of Any Website Tutorial in a very detailed way.

Buy Me a Coffee

Online Web Tutor invites you to try Skillshare free for 1 month! Learn CakePHP 4, Laravel APIs Development, CodeIgniter 4, Node Js, etc into a depth level. Master the Coding Skills to Become an Expert in Web Development. So, Search your favourite course and enroll now. Click here to join.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Was this post helpful?

Learn Web Development Courses Risk Free @ $5 only.
Web Development Courses @ $5