I met a strange thing when test the 400 error handling in CodeIgniter.
Message: Cannot modify header information - headers already sent by (output started at ...)
And the http status code is always 200, finally I found that there is a new line before <?php ...
. Then I checked the php doc, found this:
header() is used to send a raw HTTP header. See the ยป HTTP/1.1 specification for more information on HTTP headers.
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
So how to set the http status code properly in php to make sure it is before any output? I am new to php programming. Thanks for you reply!