status_header

Set HTTP status header.

Description

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

Parameters (2)

0. $code (int)
HTTP status code.
1. $description — Optional. (string) => ''
A custom description for the HTTP status.

Usage

  1. if ( !function_exists( 'status_header' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // HTTP status code. 
  5. $code = -1; 
  6.  
  7. // Optional. A custom description for the HTTP status. 
  8. $description = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = status_header($code, $description); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function status_header( $code, $description = '' ) { 
  2. if ( ! $description ) { 
  3. $description = get_status_header_desc( $code ); 
  4.  
  5. if ( empty( $description ) ) { 
  6. return; 
  7.  
  8. $protocol = wp_get_server_protocol(); 
  9. $status_header = "$protocol $code $description"; 
  10. if ( function_exists( 'apply_filters' ) ) 
  11.  
  12. /** 
  13. * Filters an HTTP status header. 
  14. * @since 2.2.0 
  15. * @param string $status_header HTTP status header. 
  16. * @param int $code HTTP status code. 
  17. * @param string $description Description for the status code. 
  18. * @param string $protocol Server protocol. 
  19. */ 
  20. $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); 
  21.  
  22. @header( $status_header, true, $code );