wp_remote_retrieve_header

函数


wp_remote_retrieve_header ( $response, $header )
参数
  • (array|WP_Error)
    $response
    HTTP response.
    Required:
  • (string)
    $header
    Header name to retrieve value from.
    Required:
返回值
  • (array|string) The header(s) value(s). Array if multiple headers with the same name are retrieved. Empty string if incorrect parameter given, or if the header doesn’t exist.
定义位置
  • wp-includes/http.php
    , line 229
引入
2.7.0
弃用

Retrieve a single header by name from the raw response.

function wp_remote_retrieve_header( $response, $header ) {
	if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
		return '';
	}

	if ( isset( $response['headers'][ $header ] ) ) {
		return $response['headers'][ $header ];
	}

	return '';
}