PHP中实现页面跳转实例
总结3种在【zhǒng zài】PHP中常用📢的页面【de yè miàn】🧚跳转方法,具体如【jù tǐ rú】下📨。
方法【fāng fǎ】1: PHP中📔 header() 函数
<?php
header("Location:http://zbbingyang.com");
?>
注意:
1. location 与【yǔ】 : 之间不📓能有空🎭格🥞,否则不会跳转【huì tiào zhuǎn】⬆。
2. header()前不能有任何【yǒu rèn hé】的输出【de shū chū】。
3. header()之后的【zhī hòu de】PHP代码还🚌会被执行。
方法2: Meta标签
Meta标签是【biāo qiān shì】HTML中负责提供文【tí gòng wén】档元信【dàng yuán xìn】息的标签【qiān】,在🥎PHP程序中🔔使用该【shǐ yòng gāi】标签【qiān】,也可以实现页面【yè miàn】✒跳转。 若定义【ruò dìng yì】➕http-equiv为refresh,则打开该页面【yè miàn】✒时将根【shí jiāng gēn】据🌻content规定的值在一🙊定时间内跳转到相应页面【yè miàn】✒。若设置content=”秒数【miǎo shù】;url=网址”,则定义⭕了经过🤕多长时🍗间后页【jiān hòu yè】🔍面跳转🈂到指定【dào zhǐ dìng】的网址。
<html>
<head>
<meta http-equiv="refresh"content="1;url=http://zbbingyang.com">
<title>HTML标题【biāo tí】</title>
</head>
<content>我爱✴PHP!</content>
</html>
方法3: javascript实现
<script language="javascript"type="text/javascript">
location.href =http://zbbingyang.com;
</script>
关键词:PHP
阅读本文后您有什么感想? 已有 人给出评价!
- 0
- 22
- 4
- 0
- 0
- 8