WP_HTTP_Response::header() public WP 4.4.0
Sets a single HTTP header.
{} It's a method of the class: WP_HTTP_Response{}
No Hooks.
Return
null
. Null. Nothing.
Usage
$WP_HTTP_Response = new WP_HTTP_Response(); $WP_HTTP_Response->header( $key, $value, $replace );
- $key(string) (required)
- Header name.
- $value(string) (required)
- Header value.
- $replace(true|false)
- Whether to replace an existing header of the same name.
Default: true
Changelog
Since 4.4.0 | Introduced. |
Code of WP_HTTP_Response::header() WP HTTP Response::header WP 5.7
public function header( $key, $value, $replace = true ) {
if ( $replace || ! isset( $this->headers[ $key ] ) ) {
$this->headers[ $key ] = $value;
} else {
$this->headers[ $key ] .= ', ' . $value;
}
}