PHP 7 Script to Send HTTP Request and HTTP Status Code as Response in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments


Welcome folks today in this blog post we will be sending http request and http status code as response in browser using php 7.All the full source code of the application is shown below.





Get Started




In order to get started you need to make an index.php file and copy paste the following code







error_reporting(E_ERROR | E_PARSE);

// Initialize a variable into domain name
$domain1 = '';

// Function to get HTTP response code
function get_http_response_code($domain1) {
    $headers = get_headers($domain1);
    return substr($headers[0], 9, 3);

// Function call
$get_http_response_code = get_http_response_code($domain1);

// Display the HTTP response code
echo $get_http_response_code;

// Check HTTP response code is 200 or not
if ( $get_http_response_code == 200 )
    echo "<br>HTTP request successfully";
    echo "<br>HTTP request not successfully!";

Leave a Reply