Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of the reasons why there can't be output before header () in php

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you in php before header () can not have output reason analysis, I believe that most people still do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

There can be no output before php header () because both the HTTP request and the HTTP response have message headers, and the message header consists of a number of header fields; if there is an output before header, it will be sent with a default request, and the message header will be determined, and the subsequent settings will be invalidated.

Why can't there be output before php header ()?

Why can't there be output before the PHP header () session_start () function?

The questions encountered in the front-line interview were not answered at that time, but I checked some information later and still did not get the answer. Today, after studying the HTTP request, I finally know the answer.

The HTTP function allows you to manipulate information sent to the browser by the Web server before other output is sent.

Both HTTP requests and HTTP responses have message headers. The message header is composed of many header fields.

That is, the message header of the request is set and then sent; if there is an output before, the default request is sent first, and the message header is determined, and the subsequent settings are invalid.

The above is all the contents of the article "Analysis of the reasons why there can't be output before header () in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report