我不明白为什么,有人帮忙吗?
最佳答案
简单:session_start设置你的php session cookie,而cookie只能在http header中设置。 php 必须先发送 header 才能开始发送内容。因此,一旦您开始输出内容,php 就会隐式发送 http header ,从而禁用更改 header 值。
防止这种情况的常见方法是使用输出缓冲 - 请参阅 http://php.net/manual/de/ref.outcontrol.php
关于php - 为什么在 Session_Start() 之前不能输出任何内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4638141/