Tips and Tricks

Causes for php Warning: Cannot modify header information - headers already sent

You will not get this error as long as you don't edit the php File created by Arclab Web Form Builder!

 

Echo before header

<?php
echo "hello world"
...
header('Location: http://...');
?>

Solution:

RemoveRemove the echo before header
Use ob_start(); and ob_end_flush(); for buffered output

 


 

New-line characters or spaces before <?php

       <?php
... header('Location: http://...');
?>

Solution:

Remove everything before <?php

 


 

BOM (Byte-Order-Mark ) in utf-8 encoded php files

 <?php
...
header('Location: http://...');
?>

Solution:

Change the file encoding to "without BOM" (e.g. using notepad++) or remove the BOM before <?php using a HEX editor

 


 

Header Location in mixed php/HTML

<html>
...
<body>
...
<?php header('Location: http://...'); >
...
</body>
</html>

Sorry, you cannot use header-location here, because the header and the HTML code have already been sent!

 


 

Empty lines, chars or spaces after ?> when using an php include file

<?php
...
?>

   ...
...

Solution:

Remove everything after ?> in the php include file