返回服务器发送的HTTP协议。
原型
wp_get_server_protocol()
返回值
(string)
HTTP协议。默认值:HTTP / 1.0。
源文件
路径:wp-includes/load.php
<?php
...
function wp_get_server_protocol() {
$protocol = $_SERVER['SERVER_PROTOCOL'];
if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
$protocol = 'HTTP/1.0';
}
return $protocol;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/wp_get_server_protocol/