Home  >  Article  >  Backend Development  >  The reason why there cannot be any output before header and session_start in php

The reason why there cannot be any output before header and session_start in php

WBOY
WBOYOriginal
2016-07-25 09:03:081145browse
The reason why there cannot be any output before header and session_start in php is that: in the http transmission text, the order of header and content must be: header first and content last

The reason why there cannot be any output before header and session_start in php is: In the HTTP transmission text, the order of header and content must be: header first and content last, and the format of the header must meet the format of "keyword: valuen".

1. If there is output content before the header is output, it will cause a misunderstanding of the header (although it is now error-tolerant). For example, if it does not meet the format of "keyword: valuen", it will be directly wrong, but it will satisfy the "keyword" format. : valuen" format, will the client install the wrong understanding, or will it be understood correctly?

2. When the session is opened, it will implicitly trigger whether to use header ("Set-Cookie: sid=xxxxxx"), which means it is actually an implicit header call.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn