很多人写程序时,用 header(location) 进行跳转往往不记得写 exit() 语句,事实上这种做法是存在严重风险的。
从浏览器上看,使用 header(location) 就跳转到另一个页面了,但事实上,php却仍然会执行后台的代码的,假如后面的代码有不安全逻辑的,那就直接无视开发者设定的条件,继续把后面的东西给执行了。
如:
if(true)
{
header('location:http://www.baidu.com');
}
file_put_contents('test.txt', 'ok');//这句此行了,生成一个test.txt文件,文件内容为ok
这个代码中,粗心的程序员会以为 header('location:http://www.baidu.com'); 就over了,事实上,后台的代码却仍然被执行了,所以使用 header(location) 的时候,不管是封装在另一个函数还是直接写的,都建议在后面加 exit() 确认程序中止。
详细解决方案
使用header()函数需要注意的有关问题
热度:81 发布时间:2012-09-19 13:43:54.0
相关解决方案
- 水晶报表,分组后 group header 和group footer同时显示(急求,谢谢)
- ASP.NET 怎么动态修改 Header 属性如添加 Meta 标签 keywords description
- 怎么实现将鼠标移到gridview的列头(header)时显示文字(tooltip)
- NND,烦死人了,Header-Detail的UI如何做
- Tivoli Tam http-header 认证模式求教
- Tivoli Tam http-header 认证方式求教!该怎么解决
- 怎么准确找到mp3 header
- HTML 五 新标签<footer> &<header>
- 惯用的HTML代码 meta编码方式、php header
- header("Conteng-type: image/png") 页面变为只有图片
- 施用ob_flush提示:E_WARNING: Cannot modify header information
- header()看似没有跳转 求帮助
- PHP header 301 的有关问题
- Cannot modify header information headr函数有关问题,代码很简单
- header("location"$url)不能用来if语句中
- CodeIgniter警告:Cannot modify header information 请高手帮忙,该如何解决
- php彻底根绝warning: Cannot add header information - headers already sent in.
- PHP header() 应用心得
- 2.wp-blog-header.php文件分析(一)
- CodeIgniter警告:Cannot modify header information 请好手帮忙
- PHP Header 缓存 - Header 参数叨明
- 登陆顺利 Warning: Cannot modify header information - headers already sent by (output
- wordpress header.php资料的疑问
- THINKPHP 框架报:XML标签语法异常 : file="Public:header"
- php header 跳转 ie有关问题
- extjs 使用 Poxy 请求webService header Content-Type设置有关问题,分不够
- PHP header 有关问题
- header("Location:index.php")页面跳转有关问题
- header()和session_start()前面不能有任何输出是什么意思,该怎么解决
- header session等各种本地和服务器有关问题