Skip to content
PHP Logo

What does the error "Cannot modify header information - headers already sent" indicate in PHP?

The error "Cannot modify header information - headers already sent" in PHP indicates that your script has already sent output to the browser before it tries to modify HTTP headers. To solve this issue, make sure that there is no whitespace or any other output before the `header()` function calls in your PHP script. You can also use output buffering to capture any output before sending headers.

php
<?php
ob_start(); // Start output buffering

// Your PHP code here

ob_end_flush(); // Flush output buffer and send output