There are several jump methods in php

藏色散人
Release: 2023-03-11 12:44:02
Original
5129 people have browsed it

php has three jump methods, which are: 1. Use the Header function, with statements such as "Header("Location: $url");"; 2. Use META's REFRESH mark to jump; 3. Use echo to print out the script code and jump.

There are several jump methods in php

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

How many jump methods are there for php?

1. Use the Header function

For example, after the logic is established, jump to the login.php page.

<?php
Header("Location: loging.php"); 
# URL也可以使用变量
 ## Header("Location: $url"); 
 
?>
Copy after login

You need to pay attention to the syntax. There is a space after Location:. You need to pay special attention to the usage: when using the Header function to jump to the page, do not put it at the top. If there is HTML in front of the statement, an error will be reported directly.

2. Using HTML tags

is actually using the REFRESH tag of META.

<? if(!isset($url)) exit;?> 
<HTML> 
<HEAD> 
<META HTTP-EQUIV="REFRESH" CONTENT="5; URL=<? echo $url;?>> 
</HEAD> 
<BODY> 
</BODY> 
</HTML>
Copy after login

First determine whether the url link exists, and if it exists, jump.

3. Using JS script

In fact, you use echo to print out the script code, and you are responsible for using the location.href API to jump.

<?php
$url="http://www.baidu.com"; 
echo "<!--<scrīpt LANGUAGE="Javascrīpt">"; 
echo "location.href=&#39;$url&#39;"; 
echo "</scrīpt>-->"; 
?>
Copy after login

Use JS to complete the jump.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of There are several jump methods 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!