Home >Backend Development >PHP Problem >How to achieve jump in php but the link remains unchanged
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.
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 = '?id=23&sth=test'; //param 拼接 比如id这里拼接+1 header('Location://xx.com/path/to/test.php'.$param);
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 '执行到第'.$id,'2秒后处理另外任务' echo '<meta http-equiv="Refresh" content="2;url=test.php?param=test" />'; //还有一种是js <script language="javascript"> //window.location.href = 'test.php?param=test'; </script>
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
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!