尽管寻找答案,但我遇到了一个无法解决的问题。这是 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 代码之前..