wp_remote_retrieve_response_code

函式
wp_remote_retrieve_response_code ( $response )
引數
  • (array|WP_Error) $response HTTP response.
    Required:
返回值
  • (int|string) The response code as an integer. Empty string if incorrect parameter given.
定義位置
相關方法
wp_remote_retrieve_response_messagewp_remote_retrieve_cookiewp_remote_retrieve_headerwp_remote_retrieve_cookieswp_remote_retrieve_body
引入
2.7.0
棄用
-

wp_remote_retrieve_response_code: 該函式從通過wp_remote_request函式傳送的遠端HTTP請求的HTTP響應頭中檢索HTTP響應程式碼。

僅從原始響應中檢索響應程式碼。

如果給定的引數值不正確,將返回空字串。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_remote_retrieve_response_code( $response ) {
if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) {
return '';
}
return $response['response']['code'];
}
function wp_remote_retrieve_response_code( $response ) { if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) { return ''; } return $response['response']['code']; }
function wp_remote_retrieve_response_code( $response ) {
	if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) {
		return '';
	}

	return $response['response']['code'];
}

常見問題

FAQs
檢視更多 >