drupal_set_header

Definition

drupal_set_header($header = NULL)
includes/common.inc, line 134

Description

Set an HTTP response header for the current page.

Note: when sending a Content-Type header, always include a 'charset' type too. This is necessary to avoid security bugs (e.g. UTF-7 XSS).

Code

<?php
function drupal_set_header($header = NULL) {
  // We use an array to guarantee there are no leading or trailing delimiters.
  // Otherwise, header('') could get called when serving the page later, which
  // ends HTTP headers prematurely on some PHP versions.
  static $stored_headers = array();

  if (strlen($header)) {
    header($header);
    $stored_headers[] = $header;
  }
  return implode("\n", $stored_headers);
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.