【问题标题】:Getting an error with PHP sessions [duplicate]PHP会话出错[重复]
【发布时间】:2013-07-24 15:06:31
【问题描述】:

我正在用 PHP 编写一个页面,但会话代码有问题。这是我的第一行代码:

<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<?php require '/home/fixit/Background/inc.inc'; ?>


<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<link rel="stylesheet" type="text/css" href="css.css" />
</head>

问题是,当我上传它时,我收到了这个错误:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/fixit/public_html/index.php:1) in /home/fixit/public_html/index.php on line 1

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/fixit/public_html/index.php:1) in /home/fixit/public_html/index.php on line 1

我已经在网上提取了页面源代码,发现它在我的会话之前放入了一个小代码,只是一个简单的&lt;br /&gt;

我正在使用 Microsoft Expression Web(第一个)对此进行编码,非常感谢任何帮助。谢谢

【问题讨论】:

  • 最常被问到的 S.O php 问题。

标签: php session microsoft-expression-web


【解决方案1】:

必须首先调用 session_start() 方法。因为 ira 创建了一个 cookie,而这在任何输出之后都是不可能的。所以看看是否有空格,可能在 ?>... 这些都不能引发这个错误...

【讨论】:

  • 你没看到他的剧本吗……看看第一行……你看到了什么……
  • 是的,你的权利。但也许他的这个网站是从另一个网站出来的?我刚刚回答了这个错误是什么意思。
  • 我的代码前面根本没有空格,还有什么可能导致这个?
  • 嗯,你在用哪个编辑器工作?
  • 尝试用这行创建一个新页面: 并运行它。那你还得到错误吗?
猜你喜欢
  • 2014-02-20
  • 2012-05-19
  • 2017-08-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-07
相关资源
最近更新 更多