Common page jump methods in php _ PHP Tutorial

Source: Internet
Author: User
A summary of common page jump methods in php. Common page jump methods of php are summarized. in php writing, user page jumps are sometimes made. several good jump methods are collected here, which can be used. Use HTTP header information, that is, use common page jump methods of php to summarize

In php writing, user page jumps are sometimes made. several good jump methods are collected here, which can be used.

Implement with HTTP header information

That is, use the php header function. The HEADER function in PHP is used to send control commands that should have been specified by the HTTP protocol to the browser through the WEB server, such as declaring the type of returned information ("Context-type: xxx/xxx "), page attributes (" No cache "," Expire "), and so on.
To redirect an HTTP header to another page, follow these steps:

The code is as follows:


If (isset ($ url ))
{
Header ("HTTP/1.1 303 See Other ");
Header ("Location: $ url ");
Exit ;//
}
?>

Mark with HTML

The HTML tag is the REFRESH tag of META, for example:

The code is as follows:






$ Url = "http://www.3LIAN.net ";
Echo" ";
?>

Use html features

The code is as follows:


Echo "<meta http-equiv = \" Refresh \ "content = \" seconds; url = redirected file or address \ "> ";

Where: XX indicates the number of seconds, and 0 indicates the jump immediately. refresh indicates the refresh. Url indicates the page to jump.

Implement with script

The code is as follows:


Echo 'script url = "submit. php"; window. location. href = url; script ';

Another method is implemented using script.

The use of scripts is different from the use of open statements. the original window, parent window, child window, or new window can be restricted.

The code is as follows:


Script url = "submit. php"; window. open (\ 'URL, \ ', \' _ self \ '); script

Change \ '_ self \' to limit whether the original window is a parent window, a subwindow, or a new window. 7. use the php built-in function to send the header information.

The code is as follows:


Header ("Location: Url ");

Fast and powerful... but there is a problem that must be pointed out: if there is html output before using this function, even if it is a space. the error message is displayed at the top of the page ..

Pipeline sometimes redirects user pages in php writing. several good jump methods are collected here, which can be used. Use HTTP header information, that is, use...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.