Definitions of common headers in PHP _ PHP Tutorial

Source: Internet
Author: User
Summary of common header definitions in PHP. Summary of definitions of common headers in PHP this article mainly introduces the definitions of common headers in PHP, which is very comprehensive and meticulous. For more information, see. He PHP common header definition summary

This article mainly summarizes the definitions of common headers in PHP, which are very comprehensive and meticulous. For more information, see.

The header () function sends the original HTTP header to the client.

It is important to realize that the header () function must be called before any actual output is sent (in PHP 4 and later versions, you can use the output cache to solve this problem):

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

Header ('http/1.1 200 OK '); // OK for normal access

Header ('http/1.1 404 Not Found '); // notifies the browser that the page does Not exist

Header ('http/1.1 301 Moved Permanently '); // Set the address to be Permanently redirected to 301

Header ('Location: http://www.ithhc.cn/'); // jump to a new address

Header ('refresh: 10; url = http://www.ithhc.cn/'); // latency redirection is the jump every few seconds

Header ('x-Powered-By: PHP/6.0.0 '); // modify the X-Powered-By information

Header ('content-language: en'); // document language

Header ('content-Length: 1234 '); // you can specify the Content Length.

Header ('last-Modified :'. gmdate ('d, d m y h: I: S', $ time ). 'gmt'); // tell the browser the last modification time

Header ('http/1.1 304 Not modified'); // tells the browser that the document content has Not changed

### Content type ###

Header ('content-Type: text/html; charset = utf-8 '); // webpage encoding

Header ('content-Type: text/plain '); // plain text format

Header ('content-Type: image/jpeg '); // JPG, JPEG

Header ('content-Type: application/zip'); // zip file

Header ('content-Type: application/pdf '); // pdf file

Header ('content-Type: audio/mpeg '); // audio File

Header ('content-type: text/css '); // css file

Header ('content-type: text/javascript '); // js file

Header ('content-type: application/json'); // json

Header ('content-type: application/pdf '); // pdf

Header ('content-type: text/XML'); // xml

Header ('content-Type: application/x-shockw ** e-Flash'); // flash animation

######

### Declare a downloaded file ###

Header ('content-Type: application/octet-stream ');

Header ('content-Disposition: attachment; filename = "ITblog.zip "');

Header ('content-Transfer-Encoding: binary ');

Readfile('test.zip ');

######

### Disable caching for the current document ###

Header ('cache-Control: no-Cache, no-store, max-age = 0, must-revalidate ');

Header ('expires: Mon, 26 Jul 1997 05:00:00 GMT ');

######

### Display a login dialog box to be verified ###

Header ('http/1.1 401 unauthorized ');

Header ('www-Authenticate: Basic realm = "Top Secret "');

######

### Declare an xls file to be downloaded ###

Header ('content-Disposition: attachment; filenameithithhc.xlsx ');

Header ('content-Type: application/vnd. openxmlformats-officedocument.spreadsheetml.sheet ');

Header ('content-Length: '. filesize ('./test.xls '));

Header ('content-Transfer-Encoding: binary ');

Header ('cache-Control: must-revalidate ');

Header ('pragma: public ');

Readfile ('./test.xls ');

######

?>

The above is all the content of this article. I hope you will like it.

Http://www.bkjia.com/PHPjc/1018928.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1018928.htmlTechArticlePHP commonly used header definition summary this article mainly to give you a summary of the PHP commonly used header definition, very comprehensive and meticulous, a small partner can refer to the next. He...

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.