PHP program to print the server protocol

Here, we are going to learn how to print the server protocol in PHP?
Submitted by Nidhi, on November 24, 2020 [Last updated : March 14, 2023]

Getting Server Protocol

Here, we will use $_SERVER['SERVER_PROTOCOL'] superglobal to get the server protocol and then print that on the webpage.

PHP code to get the server protocol

The source code to print the server protocol is given below. The given program is compiled and executed successfully.

<?php
//PHP program to print the server protocol.

$ServerProtocol = $_SERVER['SERVER_PROTOCOL'];

printf("Server Protocol: %s<br>", $ServerProtocol);
?>

Output

Server Protocol: HTTP/1.1

Explanation

In the above program, we used $_SERVER['SERVER_PROTOCOL'] super global that returns the server protocol, which is assigned to the variable $ServerProtocol. After that, we printed the server protocol on the webpage.

More PHP Programs »





All PHP Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.