首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP与模板与代码加密/优化 » [原创]header讨论  


  作者:slopesun
  注册时间:2004-09-07
  主题/回复:58/67
  积分:753
  等级:★★★(六级)
  称号:声名鹊起

  ken.wang@esolux...
  185627321
  www.

 

 发表:2005-03-29 04:58:33 阅读 2286 次 回复 1 次 得分1  |   字号 字色
[原创]header讨论
mytest.php

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<?
if($_POST[hidd])
{
    Header("location: frame.php");
}
?>
<form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']?>">
  <table width="500" border="1" cellspacing="0" cellpadding="0">
    <tr>
  <td>验证:
  <input name="hidd" type="hidden" id="hidd" value="1"></td>
  <td><input name="number" type="text" id="number"></td>
    </tr>
    <tr>
  <td> </td>
  <td><input type="submit" name="Submit" value="提交"></td>
    </tr>
  </table>
</form>
</body>
</html>

这样的结果是
Warning: Cannot modify header information - headers already sent by (output started at E:\www\mytest.php:7) in E:\www\mytest.php on line 10

如果把
<?
if($_POST[hidd])
{
    Header("location: frame.php");
}
?>
移到<html>前就能正常跳转,从上面我只能看出header()前面不能有输出,这个和session_start()一样,大家讨论一下header()还有没有其他特殊或比较容易出错的用法。在baidu上搜索了header()的用法都没有找到有讲的比较清楚的。
 
 1#楼  
 
  回复人:一起PHP
  注册时间:2004-02-27
  主题/回复:247/1521
  积分:4649
  等级:★★★★★☆(十一级)
  称号:论坛圣人

   
 1#楼 发表于2005-03-29 16:33:39  评分:1 

详细情况参看
PHP在线手册->函数参考->HTTP函数->header()
  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.005sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版