我有2页,一个是index.php,另一个是classes.php
不应该这样工作classes.php:
<?php
ob_start();
session_start();
?>
的index.php:
<?php
include "classes.php";
error_reporting(E_ALL);
echo "Loaded";
?>
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /public_html/index.php:1) in /public_html/includes/classes.php on line 2
答案 0 :(得分:3)
确保在类和索引文件中打开<?php
标记之前没有空格。
答案 1 :(得分:2)
确保在执行有关会话的任何内容之前不发送任何内容。
这意味着:
<?php
之前删除所有内容,?>
代码(它们不是必需的,通常也是有害的),您遇到的问题是由<?php
文件中的“index.php
”之前的内容引起的(可能是空格,标签,行尾或您未向我们展示的任何内容),但如果您遵循上述规则,在进一步开发应用程序时,您应该更少地解决此问题。
答案 2 :(得分:1)
这不是一个包含问题 - 你在某个地方有空格,可能在?>
之后的classes.php中。
答案 3 :(得分:1)
output started at /public_html/index.php:1
显然,您在index.php文件中的PHP开始标记之前有空格(或可能是内容),该文件将作为输出发送。
答案 4 :(得分:0)
检查你的php.ini,看看你是否将session.auto_start
设置为1(或者是真,或是)。
如果要手动启动会话,则应将其设置为0
此处有更多信息:http://www.php.net/manual/en/session.configuration.php#ini.session.auto-start
如果它已经设置为0,那么你在index.php的开头有一个空格或一个新行,试着确保你没有看到任何奇怪的字符