Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set common content-type values for header in php

Shulou Source: shulou.com Published: 2022-06-03 18:49:58 11月12日 Update

This article mainly introduces "how to set common content-type values in header in php". In daily operation, I believe many people have doubts about how to set common content-type values in php. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to set common content-type values in php header". Next, please follow the editor to study!

In PHP, you can send header information through the header function, and you can also set the content-type of the file. Here are some content-type values for common file types.

/ / date 2015-06-22 Content-Type:text/html;charset=utf-8 / define the code header ('Content-Type:text/html;charset=utf-8'); / / Atomheader ('Content-type: application/atom+xml'); / / CSSheader (' Content-type: text/css'); / / Javascriptheader ('Content-type: text/javascript'); / / JPEG Imageheader (' Content-type: image/jpeg'); / / JSONheader ('Content-type: application/json'); / / PDFheader (' Content-type: application/pdf') / / RSSheader ('Content-Type: application/rss+xml; charset=ISO-8859-1'); / / Text (Plain) header ('Content-type: text/plain'); / / XMLheader (' Content-type: text/xml'); / / okheader ('HTTP/1.1 OK'); / / set a 404 header: header (' HTTP/1.1 404 Not Found'); / / set the address to be permanently redirected header ('HTTP/1.1 301 Moved Permanently') / / go to a new address header ('Location: http://www.example.org/'); / / File delay redirection: header (' Refresh: 10; url= http://www.example.org/');print 'You will be redirected in 10 seconds'; / / of course, you can also use HTML syntax to implement / /

Tags: Files common learning content documents types addresses more browsers help browsing utility next information functions animation available through dialog boxes text articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Microsoft Shulou Information NVidia Xiaomi