[英]php session_start()-phpDesigner
I know this has been asked many times but my code works fine with no errors when it runs on the hosting company's server. 我知道这个问题已经被问过很多次了,但是当我的代码在托管公司的服务器上运行时,我的代码运行正常,没有错误。 I only get this error when I run it from phpDesigner:
当我从phpDesigner运行它时,只会出现此错误:
PHP Warning: session_start(): Cannot send session cookie - headers already sent in C:\Development\PHP_Projects\BrothersNetLogger\index.php on line 3 PHP Stack trace: PHP 1. {main}()
The index.php starts like this: index.php开始是这样的:
<?php
ob_start();
session_start();
?>
I have tried every fix suggested in the forum with no luck. 我尝试了论坛中建议的所有修复措施,但都没有碰到运气。 It would seem that the problem is specific to phpDesigner.
看来问题是特定于phpDesigner的。 Any suggestions are welcome.
欢迎任何建议。
ob_start — Turn on output buffering ob_start —打开输出缓冲
If by default your output_buffering is Off and you have been unfortunate enough to send a single byte of data back to the client then your HTTP headers have already been sent. 如果默认情况下,您的output_buffering为Off,并且您很不幸地将单字节数据发送回客户端,则您的HTTP标头已经发送。 Which effectively prevents session_start() from passing the cookie header back to the client.
这有效地阻止了session_start()将cookie标头传递回客户端。 By calling ob_start() you enable buffering and therefore delay sending http headers.Maybe you get PHP Warning: session_start(): Cannot send session cookie - headers already sent..
通过调用ob_start()可以启用缓冲,因此延迟发送HTTP标头。也许您会收到PHP警告:session_start():无法发送会话cookie-标头已发送。
<?php
session_start();
ob_start();
?>
instated of 复活的
?php
ob_start();
session_start();
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.