Home > Backend Development > PHP Tutorial > header()和session_start()前面不能有任何输出是什么意思,该怎么解决

header()和session_start()前面不能有任何输出是什么意思,该怎么解决

WBOY
Release: 2016-06-13 10:15:48
Original
1107 people have browsed it

header()和session_start()前面不能有任何输出是什么意思
这个是common.php里的一个函数:[code=PHP][/code]function checkUservalidate(){
session_start();
if(empty($_SESSION['loginuser'])){
  header("Location:login.php?errno=1");
 }
}[/code]

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><meta http-equiv="content-type" content="text/html;charset=utf-8"><script type="text/javascript"><!--     function confirmDel(val){        return window.confirm("是否要删除id="+val+"的用户");     }//---></script><?phprequire_once 'common.php';checkUservalidate();require_once 'empservice.class.php';require_once 'fenyepage.php';
Copy after login

为什么require_once 'common.php';
checkUservalidate();不是已经放在php代码的最前头了吗 ,前面不是没有任何输出了?为什么出错?
一定在html标记前面例外写一段代码包含这两句话吗

------解决方案--------------------
放在前面的最终目的还是防止提前输出。
------解决方案--------------------
去了解一下http协议吧
------解决方案--------------------
缓存溢出
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template