Question

I have a php server script that loops through session id's, and checks their values, and I'd like to output text for debugging reasons, but I get the 'Headers already sent' error (Which is expected) ... So I was wondering if there was a way to output text without sending headers ... This may be the stupidest question I've ever asked, but hey Lol

Was it helpful?

Solution

You could use the ob_start function, which starts output buffering and which will result in the header function not throwing the error message.

You could also use a file (file_put_contents).

Or like Collin Grady said: If it's just for debugging, ignore the warnings, read the information you need and remove the debug prints again.

OTHER TIPS

You're getting that error because you're sending a header later in the file. If you only need the debugging info and don't care about the rest of the script running, just exit; after you print your debug info; this will terminate the script right there, allowing you to see the debug info without your later header() calls triggering an error.

ob_start() will be helpful.

You can also check this http://phpdebugbar.com/ generally for debug :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top