Home > Backend Development > PHP Tutorial > How to jump to php page

How to jump to php page

巴扎黑
Release: 2023-03-02 15:06:01
Original
1273 people have browsed it

In the past few days, when I used PHP to write novel site code, I found that using header() to jump would sometimes report an error. I don’t know the reason. I checked online and some people said it was caused by something being output earlier, and some said it was caused by something being outputted earlier. It's a problem with UTF8. Before I figured it out, I found a few other jump methods and also realized this function. Let's briefly introduce it below.


1. Use HTTP header information


That is, use PHP’s HEADER function. The function of the HEADER function in PHP is to issue control instructions to the browser that should be passed through the WEB server specified by the HTTP protocol, such as declaring the type of return information ("Context-type: xxx/xxx"), the attributes of the page ("No cache", "Expire"), etc.
The method of redirecting to another page using HTTP header information is as follows:

<?
if (isset($url))
{
Header("HTTP/1.1 303 See Other");
Header("Location: $url");
exit;
}
?>
Copy after login

Note that there is a space after "Localtion:".

Second, use HTML tags


Use HTML tags, that is, use REFRESH tags of META, for example:

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


Three, use scripts to implement


For example:

<?
$url="http://www.PHPuser.com";
echo "<!--<SCRIPT LANGUAGE="JavaScript">";
echo "location.href=&#39;$url&#39;";
echo "</SCRIPT>-->";
?>
Copy after login

src="/ inc/gad/ad2.js">


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