返回介绍

status_header()

发布于 2017-09-11 10:29:20 字数 3093 浏览 935 评论 0 收藏 0

status_header( int $code,  string $description = '' )

Set HTTP status header.


description


参数

$code

(int) (Required) HTTP status code.

$description

(string) (Optional) A custom description for the HTTP status.

Default value: ''


源代码

File: wp-includes/functions.php

function status_header( $code, $description = '' ) {
	if ( ! $description ) {
		$description = get_status_header_desc( $code );
	}

	if ( empty( $description ) ) {
		return;
	}

	$protocol = wp_get_server_protocol();
	$status_header = "$protocol $code $description";
	if ( function_exists( 'apply_filters' ) )

		/**
		 * Filters 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 );
}

更新日志

Versiondescription
4.4.0Added the $description parameter.
2.0.0Introduced.

相关函数

Uses

  • wp-includes/load.php: wp_get_server_protocol()
  • wp-includes/functions.php: get_status_header_desc()
  • wp-includes/functions.php: status_header
  • wp-includes/plugin.php: apply_filters()

Used By

  • wp-includes/IXR/class-IXR-server.php: IXR_Server::serve()
  • wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::ajax_insert_auto_draft_post()
  • wp-includes/customize/class-wp-customize-selective-refresh.php: WP_Customize_Selective_Refresh::handle_render_partials_request()
  • wp-includes/embed.php: _oembed_rest_pre_serve_request()
  • wp-includes/rest-api/class-wp-rest-server.php: WP_REST_Server::set_status()
  • wp-includes/pluggable.php: wp_redirect()
  • wp-includes/class-wp.php: WP::handle_404()
  • wp-includes/class-wp.php: WP::send_headers()
  • wp-includes/functions.php: wp_send_json()
  • wp-includes/functions.php: dead_db()
  • wp-includes/functions.php: _default_wp_die_handler()
  • wp-includes/functions.php: _ajax_wp_die_handler()
  • wp-includes/http.php: send_origin_headers()
  • Show 8 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文