HTTP Headers

You can add headers to the HTTP response in PHP using the header() function. Since the response headers are sent before any of the actual response data, you have to send these headers before outputting any data. So, put any such header calls at the top of your script.

Redirection

<?php header('Location: http://php.w3clan.com')?>

Setting a Last-Modified Header

<?php 

    header('Last-Modified: '.gmdate('D, d M Y H:i:s',getlastmod()).' GMT');

?>

 

Show all Sent Headers

<?php

if (headers_sent()) {
    foreach (headers_list() as $hdr) echo $hdr.'<br>';
}

?>

Avoid all Caching

<?php

header('Cache-Control: no-cache, must-revalidate');

header('Pragma: no-cache');

header('Expires: Mon,26 Jul 1980 05:00:00 GMT');

?>

Loading ...

Related Results :

  1. HTTP Headers
Note :
  • Related Posts are generally User Blog posts.
  • or Other tutorials from other networks of w3clan.com.
  • Any registered user can create related posts based on search term tags.

About the Author