Ask a simple header function for PHP about the problem

Source: Internet
Author: User
Ask a simple header function question for PHP
Header (' Content-type:image/pjpeg ');
Header (' content-type:application/force-download ');
Header (' content-disposition:attachment; Filename= '. $name. ');
Header (' Content-length: '. strlen ($content));


What do these all mean? It seems to be very important, I know the header is the string that the server sends to the browser before the HTML data is transmitted by the HTTP protocol.

But I still do not have the consciousness and the concept to the header, what has it sent to whom? Is this equivalent to a handshake signal? Or what?
I'm confused.

------Solution--------------------
The server HTTP protocol response header information after the request.

HTTP (hypertexttransferprotocol) is an abbreviation for Hypertext Transfer Protocol, which is used to transmit data of WWW mode, please refer to RFC2616 for details of HTTP protocol. The HTTP protocol uses the request/response model. The client sends a request to the server that contains the requested method, URI, protocol version, and a mime-like message structure that contains the request modifier, customer information, and content. The server responds with a status line that includes the version of the message protocol, success or error encoding plus the server information, entity meta information, and possible entity content.

Typically HTTP messages include client-to-server request messages and server-to-client response messages. These two types of messages consist of a starting line, one or more header fields, a blank line that is just the end of the head field, and an optional message body. The header fields of HTTP include the general header, the request header, the response header, and the four parts of the entity header. Each header field consists of a domain name, a colon (:), and a domain value of three parts. Domain names are case-insensitive, you can add any number of whitespace before the domain value, and the header field can be expanded to multiple lines, at the beginning of each line, with at least one space or tab.
------Solution--------------------
Header (' Content-type:image/pjpeg '); Type of output
Header (' content-type:application/force-download ');
Header (' content-disposition:attachment; Filename= '. $name. '); Download the name of the display
Header (' Content-length: '. strlen ($content));

Just remember the two.
Go to Dinner first ...
------Solution--------------------
HTTP protocol, do not understand is not possible.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.