Home  >  Article  >  Backend Development  >  PHP realizes that the page to be jumped is refreshed once

PHP realizes that the page to be jumped is refreshed once

藏色散人
藏色散人Original
2021-06-26 09:14:022994browse

php method to refresh the page to be jumped: first open the corresponding PHP page code; then implement the jump through the header; finally through "header('refresh:3; url=index.php') ;" Just implement the jump and refresh.

PHP realizes that the page to be jumped is refreshed once

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php refreshes the page to be jumped

The code is as follows:

PHP page jump:

// 只是跳转,所以一定要用die();或者exit;终止下一步操作;
header('location:index.php');
exit;
// 等待3秒,跳转并刷新
header('refresh:3; url=index.php');

Related introduction:

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

It's important to realize that the header() function must be called before any actual output is sent (in PHP 4 and above, you can use output caching to solve this problem):

<html>
<?php
// 结果出错
// 在调用 header() 之前已存在输出
header(&#39;Location: http://www.example.com/&#39;);
?>

Grammar

header(string,replace,http_response_code)

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of PHP realizes that the page to be jumped is refreshed once. 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