search
Homephp教程php手册PHP URL 重定向 的三种方法(转)

PHP URL 重定向 的三种方法(转)

Jun 13, 2016 am 10:51 AM
headerhttpphpurlusefunctionsupplymethodofRelatedchangeRedirect

[使用header()函数】
PHP的HTTP相关函数种提供了一个 header()函数,首先要清楚,header()函数必须放在php程序的开头部分,而且之前不能有另外的 header() 函数或者 setcookie() 被调用,如果是带有网页输出,本语句必须放在

标记之前。

使用如下语句:


header("location: http://www.bibias.com");
exit;
?>

只要执行这个语句就将自动把网页重定向到 http://www.bibias.com


【使用HTML标记重定向】





if(isset($url))
{
echo "";
}
?>




其中的 CONTENT="5;url=$url" 表示5秒后,本网页将自动转向 $url这个地址。


【用js脚本实现重定向】




$url="http://www.bibias.com";
echo "";
?>

没多少时间详细了解,倾向于用javascript这个
作者:青一

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),