PHP session_start();

Pie*_* A. 1 php session

我正在尝试使用PHP的Sessions,我session_start();在我的开头使用它,index.php但得到以下错误消息:

警告:session_start()[function.session-start]:无法发送会话cookie - 已经在/home/ideal906/public_html/index.php中发送的输出(输出从/home/ideal906/public_html/index.php:1开始)在第2行

警告:session_start()[function.session-start]:无法发送会话缓存限制器 - 已在/home/ideal906/public_html/index.php中发送的标头(输出从/home/ideal906/public_html/index.php:1开始)在第2行

这很奇怪,这是我网站的第一行:

<?php
    session_start();
?>

<!DOCTYPE html>
<html>
    <head>
<meta charset="utf-8" />
        <meta name="author" content="Pierre Anken">
        <meta name="description" content="Outil de création de menus équlibrés selon vos besoins">
        <!--[if lt IE 9]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="jquery.js"></script>
        <script src="scripts.js"></script>
        <link rel="stylesheet" href="style.css" />
        <title>Composez vos menus</title>
    </head>
    <body>
        <section id='sectionCentre'>
            <div id='presentation'>
                <h2>Ideal Menu</h2>

            </div>
        </section>
        <section id='bandeauHautDoite'>
            <nav>
                <ul>
                    <a href='#' elementMenu='monCompte' id='monCompte'>Mon compte</a><br/>
                    <a href='#' elementMenu='mesMenus' id='mesMenus'>Mes menus</a><br/>
                    <a href='#' elementMenu='mesRepas' id='mesRepas'>Mes repas</a><br/>
                    <a href='#' elementMenu='contact' id='contact'>Contact</a><br/>
                </ul>
            </nav>
        </section>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

bor*_*ble 5

您有一个(不可见的)BOM(字节顺序标记),它由编辑器放在文件的开头.它正在输出之前session_start()使您的页面无法更改HTTP标头.删除BOM,问题就会消失.