wp_get_server_protocol

Return the HTTP protocol sent by the server.

Description

(string) wp_get_server_protocol(); 

Returns (string)

The HTTP protocol. Default: HTTP/1.0.


Usage

  1. if ( !function_exists( 'wp_get_server_protocol' ) ) { 
  2. require_once ABSPATH . WPINC . '/load.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_get_server_protocol(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/load.php  
  1. function wp_get_server_protocol() { 
  2. $protocol = $_SERVER['SERVER_PROTOCOL']; 
  3. if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { 
  4. $protocol = 'HTTP/1.0'; 
  5. return $protocol;