search
HomeBackend DevelopmentPHP ProblemHow to use header() in php to jump to the page?

How to use header() in php to jump to the page?

Aug 21, 2020 am 11:47 AM
header()phpJump page

php method to use header() to jump to the page: 1. Use "header('Location:url page address');" to jump to the page immediately; 2. Use "header('Refresh:time,Url =url page address');" Jump to the page at the specified time (seconds).

How to use header() in php to jump to the page?

Recommended: "PHP Video Tutorial"

php uses header() to jump Page methods

#1. Jump to the page immediately

header('Location:url页面地址');  //Location和":"之间无空格

Example:

header('Location:other.php');
//file_put_contents('bee.txt','execute');
die;

When executing the header, It does not end immediately, but will complete the execution of the page; there cannot be any output in front of the header. If the output buffer is turned on, no error will be prompted.

php.ini->output_buffering = 4096|OFF

2. Jump to the page regularly

header('Refresh:time,Url=url页面地址');

Example:

header('Refresh:3,Url=http://www.php.cn/');   //3s后跳转
echo '3s 后跳转';
//由于只是普通页面展示,提示的样式容易定制
die;

Description:

header() function sends the original HTTP header to the client.

It is important to realize that the header() function must be called before any actual output is sent

Related learning recommendations: PHP Programming from Beginner to Mastery

The above is the detailed content of How to use header() in php to jump to the page?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment