Chris Muench
Chris Muench

Reputation: 18338

Cannot modify header information - headers already sent by NOT be displayed with E_ALL error_reporting

I don't have output buffering on AND display_errors is On and error_reporing is E_ALL, but on my server a php warning is not displayed.

The warning I am expecting is:

Cannot modify header information - headers already sent by " when it is expected.

The server that is not displaying the error is Mac OS X php 5.4.24. The server that IS displaying the cent os php 5.3.27. Both have E_ALL error reporting

Code that should cause error on both servers:

echo json_encode(array('success'=>true,'message'=>$success_message,'person_id'=>$employee_id,'redirect_code'=>$redirect_code));
$this->session->set_flashdata('manage_success_message', $success_message);

My question is:

Why am I NOT getting warning from my Mac OS X machine; but am getting a warning from cent os. The php versions are slightly different, but I wouldn't think this behavior would change.

Upvotes: 0

Views: 411

Answers (2)

Chris Muench
Chris Muench

Reputation: 18338

I modified the following in php.ini and was able to get the problem to happen on my mac server:

FROM:

output_buffering = 4096

TO:

output_buffering = Off

This seems to be the problem.

Upvotes: 1

Patrick Moore
Patrick Moore

Reputation: 13354

Check for a single space, carriage return or tab before the opening <?php tag.

On both machines, try confirming your theory about error reporting settings with:

echo ini_get ( 'display_errors' );

If the environments on both your Mac and your CentOS machine are not identical in configuration, there are many plausible reasons for the difference... from error suppression to the way the OS handles EOL characters.

Upvotes: 0

Related Questions