Jump to content

Diagnosing headers already sent errors


E_Leeder

Recommended Posts

I'm trying to diagnose headers already sent errors. I know that I can see the line and comment it out (or do something) based on the error given, but what I don't understand is why they seem to occur sometimes but not others.

 

The code below sends things to the browser before calling session_regenerate_id(true), which will cause headers already sent errors if headers have already been sent.

<?php

echo 'hello world';
$test_variable = 'some variable to var_dump';
var_dump($test_variable);
session_regenerate_id();

?>

I thought that this should fail and give me a headers already sent error, but it doesn't. I frequently echo to a page before calling a header action, and sometimes it works, sometimes it doesn't, like in the case above. What's going on to give me an error elsewhere but not here?

Link to comment
https://forums.phpfreaks.com/topic/286143-diagnosing-headers-already-sent-errors/
Share on other sites

Is your experience in testing/developing, in different environments, e.g working locally with wamp or xampp or something vs. a hosted server, or multiple hosted servers? Because the most common cause is that it depends on what the error reporting levels are set at, either in the php.ini file or in some script itself.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.