wp_get_server_protocol()
Returns the HTTP protocol sent by the server.
No Hooks.
Returns
String. The HTTP protocol.0.
Usage
wp_get_server_protocol();
Changelog
| Since 4.4.0 | Introduced. |
wp_get_server_protocol() wp get server protocol code WP 7.0
function wp_get_server_protocol() {
$protocol = $_SERVER['SERVER_PROTOCOL'] ?? '';
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0', 'HTTP/3' ), true ) ) {
$protocol = 'HTTP/1.0';
}
return $protocol;
}