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

The 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, the same header information can be enforced.

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 example

Try the following example

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

The above example redirects the browser to the oldtoolbag.com website

PHP HTTP  reference manual