CakePHP: Cannot modify header information - header

2020-08-05 06:10发布

Complete error:

Warning (2): Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/trunk/dafe/cake/basics.php:355) [CORE/cake/libs/controller/controller.php, line 743]

As far as I can tell it happens after I try to redirect. I know it's caused by a whitespace but I can't find it anywhere, where does this error tend to be?

EDIT: Forgot to mention, this problem only happens on my Mac, my partner working on windows does not have this issue, redirection works appropriately for him.

3条回答
叛逆
2楼-- · 2020-08-05 06:24

I had a similar problem and tried removing white space, flush, etc... but nothing worked until I configured output_buffering to 'on' in my EZ php config interface on cpanel.

查看更多
Lonely孤独者°
3楼-- · 2020-08-05 06:28

Two possibilities I know of: A. You might have some whitespace after the class closing PHP tag ?>.

B. You are trying to echo/ pr() during the processing of the data/ logic (-while it's redirecting, saving to the database, etc)

查看更多
Summer. ? 凉城
4楼-- · 2020-08-05 06:36

I had this Problem recently myself and searched for Blanks within my Code but didnt't find one. The simple Solution: Deactivated the debug mode (Configure::write(debug,0) and everything worked fine :)

查看更多
登录 后发表回答