status_header()
status_header( int $code, string $description = ” )
设置HTTP状态标头。
Set HTTP status header.
说明(Description)
另请参阅get_status_header_desc()
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$code | (int) | HTTP状态代码。 |
$description | (string) | HTTP状态的自定义描述。 |
源码(Source)
/** * Set HTTP status header. * * @since 2.0.0 * * @see get_status_header_desc() * * @param int $code HTTP status code. */ function status_header( $code ) { $description = get_status_header_desc( $code ); if ( empty( $description ) ) return; $protocol = $_SERVER['SERVER_PROTOCOL']; if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; $status_header = "$protocol $code $description"; if ( function_exists( 'apply_filters' ) ) /** * Filter an HTTP status header. * * @since 2.2.0 * * @param string $status_header HTTP status header. * @param int $code HTTP status code. * @param string $description Description for the status code. * @param string $protocol Server protocol. */ $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); @header( $status_header, true, $code ); }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
4.4.0 | wp-includes/functions.php | 10 | 12 |
status_header() 为WP2原创文章,链接:https://www.wp2.cn/functions/status_header/