Im working with PHP 4.3.11 and when I execute a header always responds with an error like this
Warning: Cannot modify header information – headers already sent by (output started at d:\folder\file.php:1) in d:\folder\file.php on line 2
Warning: Cannot modify header information – headers already sent by (output started at d:\folder\file.php:1) in d:\folder\file.php on line 3 Current PHP version: 4.3.11
the code I used to generate this error was
<?php header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past echo 'Current PHP version: ' . phpversion(); // prints e.g. '2.0' or nothing if the extension isn't enabled echo phpversion('tidy'); ?>
It has no spaces nor newlines before or after the php tags, and the same code in a 5.x version returns just the php version as expected.
Any clue?
Thanks in advance
Edit: Solved!: I’ve opened the file with western european encoding and deleted the BOM and it worked. Thanks all for your help!
Do you have a UTF BOM at the start of the file?