首页 >函数列表 >http_response_code

http_response_code

http_response_code

(No version information available, might only be in SVN)

http_response_codeGet or Set the HTTP response code

说明

int http_response_code ([ int $response_code ] )

If you pass no parameters then http_response_code will get the current status code. If you pass a parameter it will set the response code.

参数

response_code

The optional response_code will set the response code.

<?php
http_response_code
(404);
?>

返回值

The current response code. By default the return value is int(200).

范例

Example #1 Examples using headers_list()

<?php

// Get the current default response code
var_dump(http_response_code()); // int(200)

// Set our response code
http_response_code(404);

// Get our new response code
var_dump(http_response_code()); // int(404)
?>

以上例程会输出:

参见

  • header() - Send a raw HTTP header
  • headers_list() - Returns a list of response headers sent (or ready to send)

  • checkdnsrr
  • closelog
  • define_syslog_variables
  • dns_check_record
  • dns_get_mx
  • dns_get_record
  • fsockopen
  • gethostbyaddr
  • gethostbyname
  • gethostbynamel
  • gethostname
  • getmxrr
  • getprotobyname
  • getprotobynumber
  • getservbyname
  • getservbyport
  • header
  • headers_list
  • headers_sent
  • header_register_callback
  • header_remove
  • http_response_code
  • inet_ntop
  • inet_pton
  • ip2long
  • long2ip
  • openlog
  • pfsockopen
  • setcookie
  • setrawcookie
  • socket_get_status
  • socket_set_blocking
  • socket_set_timeout
  • syslog
  • PHP MySQL HTML CSS JavaScript MSSQL AJAX .NET JSP Linux Mac ASP 服务器 SQL jQuery C# C++ java Android IOS oracle MongoDB SQLite wamp 交通频道