这里有Session_start()的问题:
警告:在session_start()[function.session启动]:无法发送会话缓存限制器-已经发送了头(输出开始在C:\ XAMPP\htdocs中\网页\ home.php:4)在C:\ XAMPP\htdocs中\图第2行的\ home-chart.php
在第2行的home-chart.php中我写了这样的代码:
session_start();
.
.
.
echo ' username: '.$_SESSION['user_name'];
Run Code Online (Sandbox Code Playgroud)
虽然有了这个警告我可以得到结果$_SESSION['user_name']但是当我试图清除这部分代码时:
session_start();
Run Code Online (Sandbox Code Playgroud)
我在屏幕上看不到任何结果.那么,你的解决方案是什么?
<?php
@session_start();
require_once '../class/chart.class.php';
$chart = new chart();
?>
<html>
<head>
<link href='../css/home-chart.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div class='float_left' style="margin-bottom:20px;">
<div class='float_left' style='line-height: 9.41px; font-size: x-small;'>0<br /></div> <div class='float_left' style="background-image: url('../image/web/chart.png'); width: 367px; height: 226px; " >
<!-- 1 --><div class='float_left float_left column' style='margin-left:2px;'>
<?php echo $chart->mysql_fetch($chart->daycal(-3)); ?>
</div>
<!-- 2 --><div class='float_left float_left column'>
<?php echo $chart->mysql_fetch($chart->daycal(-2)); ?>
</div>
<!-- 3 --><div class='float_left column' >
<?php echo $chart->mysql_fetch($chart->daycal(-1)); ?>
</div>
<!-- 4 --><div class='float_left column' >
<?php echo $chart->mysql_fetch($chart->daycal(0)); ?>
</div>
<!-- 5 --><div class='float_left column' >
<?php echo $chart->mysql_fetch($chart->daycal(1)); ?>
</div>
<!-- 6 --><div class='float_left column' >
<?php echo $chart->mysql_fetch($chart->daycal(2)); ?>
</div>
<!-- 7 --><div class='float_left column' >
<?php echo $chart->mysql_fetch($chart->daycal(3)); ?>
</div>
</div>
<div class='float_single_full' ></div>
<div class='float_left bottom_chart' style="margin-left:10px;"><?php echo $chart->dayofweek(-3); ?></div>
<div class='float_left bottom_chart'><?php echo $chart->dayofweek(-2); ?></div>
<div class='float_left bottom_chart'><?php echo $chart->dayofweek(-1); ?></div>
<div class='float_left bottom_chart' style='font-weight:bold'><?php echo $chart->dayofweek(0); ?></div>
<div class='float_left bottom_chart'><?php echo $chart->dayofweek(1); ?></div>
<div class='float_left bottom_chart'><?php echo $chart->dayofweek(2); ?></div>
<div class='float_left bottom_chart'><?php echo $chart->dayofweek(3);
echo ' username: ' . $_SESSION['user_name'];
?></div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Joe*_*Joe 15
如果您在<?php标记之前甚至有空行,则无法设置标题.带行号的文件开头应如下所示:
1. <?php
2. session_start();
3. header('Cache-control: private');
Run Code Online (Sandbox Code Playgroud)
消息显示"在第2行发送的标题",因此您在home.php的第4行输出了一些内容(空格,空白行等)
如果这个文件是include,你应该把你session_start();放在home.php的顶部,然后在这个文件中不需要它.
| 归档时间: |
|
| 查看次数: |
50939 次 |
| 最近记录: |