Home > Backend Development > PHP Problem > How many ways are there to implement page jump in php?

How many ways are there to implement page jump in php?

coldplay.xixi
Release: 2023-03-01 14:46:02
Original
2801 people have browsed it

How many ways are there to implement page jump in php?

#How many ways are there to implement page jump in php?

The ways to implement page jump in php are:

Achieved in PHP script code

<?php header("location:url address") ?> For example <?php header("location:helloworld.php")?> The page will jump immediately because the header executes location Redirect

1. Delayed jump (For example, after successful login, there will be a few seconds of waiting time, and then jump to other pages)

Code:

<?php  header("Refresh:秒数;url=地址")     ?>
Copy after login

For example:

<?php   header("Refresh:3;url=helloworld.php")?>
Copy after login

will execute the jump after 3 seconds

<?php sleep(3); header("location:url地址")?>
Copy after login

The sleep() method is called, and the effect is to execute the jump after x seconds.

2. Implement in js script code

1.window.location.href method

<script type="text/javascript">
  window.location.href="helloworld.php"          
</script>
Copy after login

Use js method to implement delayed jump Transfer

<script type="text/javascript">
  setTimeout("window.location.href=&#39;helloworld.php&#39;",3000);</script>
Copy after login

2.window.location.assign method delayed jump method is the same as above

<script type="text/javascript">window.location.assign("helloworld.php");</script>
Copy after login

3.window.location.replace method (let the new page replace the current page and will not be saved in the history In the record, you cannot use the browser to return to the original page)

<script type="text/javascript">
  window.location.replace("helloworld.php");</script>
Copy after login

4.window.open method, three parameters, the first URL address. The second is the way to open a new page (such as new page _blank, _new, self jump _self), and the third is the way to open a new page, including style, location, etc.

<script type="text/javascript">
  window.open("index.php",_blank,width=300px);</script>
Copy after login


##3. Use HTML script code to complete the jump

In the tag Execute the code

Just insert this code directly

<meta http-equiv="refresh" content="3;url=&#39;helloworld.php&#39;">
Copy after login
Recommended tutorial: "

PHP Video Tutorial"

The above is the detailed content of How many ways are there to implement page jump in php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template