博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
重定向和盲重定向_PHP重定向功能
阅读量:2511 次
发布时间:2019-05-11

本文共 861 字,大约阅读时间需要 2 分钟。

重定向和盲重定向

After form submission or a page redirect is triggered, it's commonplace to redirect the user to a different page or to the same page, formatted in a different way. Usually, you'd complete this by coding:

触发表单提交或页面重定向后,通常将用户重定向到其他页面或同一页面,并以不同的方式进行格式化。 通常,您可以通过编码来完成此操作:

header('Location:  destination.php');exit();

This is a completely acceptable way to code your pages, but I prefer to use a redirect function instead. Why? It's much more readable, and quite honestly, I'm tired of writing the header('Location: ...'); code.

这是一种完全可以接受的页面编码方法,但是我更喜欢使用重定向功能。 为什么? 它更具可读性,说实话,我已经厌倦了编写header('Location: ...'); 码。

function redirect($url, $permanent = false) {	if($permanent) {		header('HTTP/1.1 301 Moved Permanently');	}	header('Location: '.$url);	exit();}

This function is incredibly easy to use and saves a lot of code.

此功能非常易于使用,并节省了大量代码。

翻译自:

重定向和盲重定向

转载地址:http://gwpwd.baihongyu.com/

你可能感兴趣的文章
菜鸟成长记(十五)----- 要永远相信美好的事情即将发生
查看>>
JDBC
查看>>
CSS选择器
查看>>
HTML结构文档中那些基础又重要又容易被忽略的事?
查看>>
微服务的消费
查看>>
同一台电脑上个人的github账户如何与公司的gitlab账户共存
查看>>
一本通【例题4】Addition Chains——题解
查看>>
E - Cover it!
查看>>
E. 玩游戏
查看>>
mysql 必知必会 -- 一些笔记
查看>>
史上最全阿里 Java 面试题总结
查看>>
Docker命令之 search
查看>>
10/19 duiHibernate 的复习总结
查看>>
Kali更新源,亲测目前可用的源
查看>>
poj1038
查看>>
Duff and Weight Lifting - 587A
查看>>
[ios] alertview自定义提示信息【转】
查看>>
N皇后问题
查看>>
七大基本排序算法之冒泡排序
查看>>
java第七次作业
查看>>