GC_HTTP_Response::header()

最后更新于:2021-12-01 11:11:06

GC_( string$key, string$value, bool$replace=true)

Sets a single HTTP header.

参数

$key

(string) (Required) Header name.

$value

(string) (Required) Header value.

$replace

(bool) (Optional) Whether to replace an existing header of the same name.

Default value: true

源文件

文件: gc-includes/class-gc-http-response.php

	public function header( $key, $value, $replace = true ) {
		if ( $replace || ! isset( $this->headers[ $key ] ) ) {
			$this->headers[ $key ] = $value;
		} else {
			$this->headers[ $key ] .= ', ' . $value;
		}
	}