I have some problems with the header() function. It works and does not work at the same time.
The manual says:
Remember that header () must be called before any actual output is sent either by regular HTML tags, empty lines in a file, or from PHP.
Otherwise there will be an error.
But I can call header() anywhere in the html script or php code after sending the output and header() works:
<?php echo "Output here"; header("Location: http://stackoverflow.com");
Any header() works. This header("Some-Header: bar-foo") can set the header:
<!DOCTYPE html> <html> <body> ⦠some script here⦠<?php print_r(headers_list()); ⦠some script here⦠</body> </html>
How can it be? Is there something wrong with the settings?
Green source share