English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP header() function

PHP HTTP Reference Manual

The header() function sends native HTTP headers

Syntax

void header (string $string[, bool $replace = true[, int $http_response_code]])

Definition and usage

It is used to send HTTP header lines.

Return value

No value returned

Parameter

Serial numberParameters and descriptions
1

string

Header string.

2

repalce

Optional parameter replace indicates whether the header behind it replaces the previous header of the same type. By default, it will replace.

If FALSE is passed, it can force the same header information to coexist.

3

http_response_code

Forces the specified HTTP response value. Note that this parameter is only effective when the message string is not empty.

Online Examples

Try the following example

<?php
   header("Location: https:")//www.oldtoolbag.com/");   
   exit;
?>

The example above redirects the browser to oldtoolbag.com website

PHP HTTP Reference Manual