Home > php教程 > php手册 > body text

PHP程序中使用session错误调试问题

WBOY
Release: 2016-06-13 10:29:35
Original
948 people have browsed it

开发需要接触PHP,感觉上手也挺快,在调试PHP中的SESSION时总是出错,

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at XXX:2) in .php on line 3

类似错,对照源码好像自己没有哪里写错.

php开始符号

session在开始前不能有任何字符输出,

header()是一样的

将代码提前,去除前面的空格,就可以了.

-------------------正确

session_start();
$username;
$username = "test";
session_register("username");
echo $_SESSION[username];
?>

-------------------错误


session_start();
$username;
$username = "test";
session_register("username");
echo $_SESSION[username];
?>


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!