Home > php教程 > php手册 > body text

php中的多种界面跳转方式

PHP中文网
Release: 2017-04-21 10:13:35
Original
978 people have browsed it

方法1: PHP中 header() 函数

<ol class="linenums">
<li class="L0" value="1">
<?php
<li class="L1">header("Location:http://www.php.cn");<li class="L2">
?>
Copy after login

注意:
1. location 与 : 之间不能有空格,否则不会跳转。
2. header()前不能有任何的输出。
3. header()之后的PHP代码还会被执行。

方法2: Meta标签
Meta标签是HTML中负责提供文档元信息的标签,在PHP程序中使用该标签,也可以实现页面跳转。 若定义http-equiv为refresh,则打开该页面时将根据content规定的值在一定时间内跳转到相应页面。若设置content=”秒数;url=网址”,则定义了经过多长时间后页面跳转到指定的网址。

<ol class="linenums">
<li class="L0" value="1">
<html><li class="L1">
<head>
<li class="L2">
<meta http-equiv="refresh" content="1;url= 
<li class="L3">
<title>HTML标题</title>
<li class="L4">
</head>
<li class="L5">
<content>
<li class="L6">PHP中文网欢迎大家光临!<li class="L7"></content>
</html>
Copy after login

方法3: javascript实现

<ol class="linenums">
<li class="L0" value="1">
<script language="javascript" type="text/javascript">
<li class="L1">location.href = "http://www.php.cn";<li class="L2">
</script>
Copy after login


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template