Home > Backend Development > PHP Problem > How to jump to the current page in php

How to jump to the current page in php

藏色散人
Release: 2023-03-05 09:26:01
Original
4277 people have browsed it

How to jump to the current page in php: 1. Use the "Header("Location:$url");" method to realize the jump; 2. Use the if judgment to realize the jump; 3. Use "echo" "location.href='$url'";" method implements jump, etc.

How to jump to the current page in php

Recommended: "PHP Video Tutorial"

PHP implements URL address jump code

1. PHP jump code in one sentence:

<?php 
$url = $_GET[&#39;url&#39;]; 
Header("Location:$url"); 
?>
Copy after login

2. PHP jump code if judgment:

if($_COOKIE["u_type"]){ 
    header(&#39;location:register.php&#39;); 
} 
else{ 
   setcookie(&#39;u_type&#39;,&#39;1&#39;,&#39;86400*360&#39;);//设置cookie长期有效 
    header(&#39;location:zc.html&#39;); 
}
Copy after login

Note: Save as zc.php, when the user When accessing zc.php, determine whether a cookie exists. If it exists, jump to register.php. If it does not exist, create a cookie and jump to zc.html

3. PHP jump code javascript:

<?php 
$url=czbin.php; 
echo "<!--<SCRIPT LANGUAGE="javascript">"; 
echo "location.href=&#39;$url&#39;"; 
echo "</SCRIPT>-->"; 
?>
Copy after login

4. PHP jump code HTML markup (REFRESH attribute of META):

<HTML> 
<HEAD> 
<META HTTP-EQUIV="REFRESH" CONTENT="10"; URL=www.zhimengba.com/> 
</HEAD> 
<BODY> 
</BODY> 
</HTML>
Copy after login

Note: CONTENT="10" here means to jump after 10 seconds.

5. PHP jump code HTTP header information (Header function) formula:

<?php 
$url = czbin.php 
Header("HTTP/1.1 303 See Other"); 
Header("Location: $url"); 
exit;  
?>
Copy after login

The above is the detailed content of How to jump to the current page in php. 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