Method (total of three kinds) PHP redirect page jump page

HHW: the first method may be: http: //127.0.0.1/tp5 simplified http://127.0.0.1, index.php www directory file is about to write the first php code:

<?php
header('content-type:text/html;charset=uft-8');
header('location:tp5/index.php');
?>

 Or direct:

<?php
header('content-type:text/html;charset=uft-8');
header('location:tp5/public/index.php');
?>

 

The first: the use of header () function to redirect, which I also use more. (Note locationhe and! ":"! Can not have spaces between, otherwise no effect)

<? PHP
header ( 'Content-type: text / HTML; UFT-charset =. 8);
// redirect page
header (' LOCATION: the index.php ');
?>
Second: the use of HTML header meta tag, the definition and http-equiv = refresh content = "jump time taken (in seconds); url = jump address"

<! DOCTYPE HTML>
<HTML lang = "EN">
<head>
<Meta charset = "UTF-8">
// jump page, Jump Time: 3 seconds, the target address: index.php
<Meta http- = equiv "Refresh" Content = ". 3; the index.php URL =">
<title> Skip ... </ title>
</ head>

or

<? PHP
header ( 'Content-type: text / HTML; charset = UTF-. 8');
$ URL = 'the index.php';
?>
<DOCTYPE HTML!>
<HTML lang = "EN">
<head>
< charset = Meta "UTF-8">
// jump page, jump time: 2 seconds, the target address: index.php
<Meta HTTP-equiv = "Refresh" Content = "2; url = <PHP echo $? ? URL;> ">
<title> Skip ... </ title>
</ head>

third: jump using javascript

? <PHP
header ( 'Content-of the type: text / HTML; charset = UTF-8');
$ url = 'index.php';
// immediately jump to the target page
echo <script> window.location.href = ' url $ '; </ Script>;
?>

These are the three methods in PHP redirect page.
----------------
Disclaimer: This article is CSDN bloggers' yAngrUiLin ah "in the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and this link statement.
Original link: https: //blog.csdn.net/yaruli/java/article/details/78837240

Guess you like

Origin www.cnblogs.com/huhewei/p/12633701.html