【发布时间】:2013-10-10 08:49:02
【问题描述】:
我遇到了一个问题,尽管我正在寻找答案,但我仍然无法解决。 是index.php的代码:
<?php
session_start();
?>
<html>
<head>
<title>Elektromechanika Pojazdowa</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="#170266">
<center>
<div id="naglowek">ELEKTROMECHANIKA POJAZDOWA</div>
<div id="menu">
<table width="100%">
<tr>
<td width="50%">
<a class="menu" href="index.php?p=main">Strona Główna</a>
</td>
<td width="50%">
<a class="menu" href="index.php?p=contact">Kontakt</a>
</td>
</tr>
</table>
</div>
</center>
<?php
$p = $_GET['p'];
if(!empty($p))
include("$p".'.php');
else
include('main.php');
?>
<div id="stopka">
<center>
<table>
<tr>
<td width="30%">
<center><img src="img/bendiks.jpg"></center>
</td>
<td width="30%">
<center><img src="img/magneti marelli.jpg" width="300px" height="170px"></center>
</td>
<td width="30%">
<center><img src="img/bosch.jpeg"></center>
</td>
</tr>
</table>
</center>
</div>
<div id="link">
<a class="admin" href="index.php?p=admin">Panel adminitracyjny</a>
</div>
</body>
我无法让它工作,因为我收到错误:
Warning: session_start() [function.session-start]: Cannot send session cookie -
headers already sent by (output started at D:\Program Files\WebServ\httpd-users\dla
Gabi\index.php:1) in D:\Program Files\WebServ\httpd-users\dla Gabi\index.php on line 2
我尝试使用ob_start();,但它不起作用。我不明白为什么会出现问题,因为session_start(); 是第一个函数,甚至放在任何 html 代码之前..
【问题讨论】:
-
Headers already sent by PHP 的可能重复项
-
你看到右边的相关栏了吗?
-
我在相关主题中寻找答案,但没有找到帮助:(我必须以 UTF-8 编码保存文件,这是可能的问题.. 那么有什么方法可以将文件保存在UTF-8编码能解决这个问题吗?
-
好的,我发现我需要在每次保存后对文件进行十六进制编辑并删除前 3 个不可见的数字。但是有没有办法永久地做到这一点?
-
@ArkadiuszGaller 使用其他文本编辑器。