关于使用session_start出现的headers&nbsp_PHP教程

WBOY
풀어 주다: 2016-07-13 10:53:29
원래의
814명이 탐색했습니다.

请看详细的错误程序和输出结果


echo "testing ... ";
session_start();
?>

输出为
testing ...
Warning: Cannot send session cookie - headers already sent by (output started at F:php2000test.php:2) in F:php2000test.php on line 4
Warning: Cannot send session cache limiter - headers already sent (output started at F:php2000test.php:2) in F:php2000test.php on line 4
分析:
主要原因,php.ini里有关于session 的定义,默认是使用 cookie
[session]
session.use_cookies = 1 ; whether to use cookies
这句表明使用 cookies 存储session 而 cookies的设置必须在正式 htm 之前,也就是只能在 header 里面才行,所以造成这个错误的发生
我们修改程序为

echo "testing ... ";
session_start();
?>
同样错误,因为 echo 已经输出了
我们修改程序为

$i=1;
session_start();
?>
运行正确表明在session_start的前面可以有计算语句,但是不能有输出语句
我尝试过修改
session.use_cookies = 0 ; whether to use cookies
但是没有成功,希望知道答案的朋友通知我,如何去掉cookie方式的 session

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632399.htmlTechArticle请看详细的错误程序和输出结果 html ? echo "testing ... "; session_start(); ? /html 输出为 testing ... Warning: Cannot send session cookie - headers already sent by (...
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!