How to achieve jump in php but the link remains unchanged

藏色散人
Release: 2023-03-08 18:18:02
Original
2384 people have browsed it

php method to implement jump but unchanged link: first create a PHP sample file; then receive parameters; finally pass "header('Location://xx.com/path/to/test.php' .$param);" and other methods to achieve the jump.

How to achieve jump in php but the link remains unchanged

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

Specific questions:

php jumps to the page but the url remains unchanged.

I want the page to change several parameters and jump to the page again after executing a program, but the parameters of the page have changed. Is there any good way to do this?

Use the header but jump. The parameters of the URL will not change without refreshing the page.

Implementation method:

It can be done. If you are processing data or using cli mode without timeout, just call yourself recursively,

What you said is what I understand as follows:

<?php
//接收参数,do sth逻辑
$param = &#39;?id=23&sth=test&#39;; //param 拼接 比如id这里拼接+1
header(&#39;Location://xx.com/path/to/test.php&#39;.$param);
Copy after login

But it keeps jumping like this, and you can’t see clearly what has been done

There are three types of jumps

can be used meta will jump after 2 seconds

echo &#39;执行到第&#39;.$id,&#39;2秒后处理另外任务&#39;
  echo &#39;<meta http-equiv="Refresh" content="2;url=test.php?param=test" />&#39;;
//还有一种是js
<script language="javascript">
//window.location.href = &#39;test.php?param=test&#39;; 
</script>
Copy after login

The parameters are spliced ​​together

It is recommended to use the cli mode without timeout, just call your own method recursively, and print the output to the log

nohup /path/to/php test.php
Copy after login

Start There will be nohup.log

in the future. Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to achieve jump in php but the link remains unchanged. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!