分享PHP header函数使用教程
发布时间:2023-09-04 12:07:14
标签:PHP,header
<?php
// fix 404 pages:
header('HTTP/1.1 200 OK');
// set 404 header:
header('HTTP/1.1 404 Not Found');
// set Moved Permanently header (good for redrictions)
// use with location header
header('HTTP/1.1 301 Moved Permanently');
// redirect to a new location:
header('Location: http://www.example.org/');
// redrict with delay:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';
// you could also use the HTML syntax:// <meta http-equiv="refresh" content="10;http://www.example.org/ />
// override X-Powered-By: PHP:
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');
// content language (en = English)
header('Content-language: en');
// last modified (good for caching)
$time = time() – 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// header for telling the browser that the content
// did not get changed
header('HTTP/1.1 304 Not Modified');
// set content length (good for caching):
header('Content-Length: 1234');
// Headers for an download:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
// load the file to send:readfile('example.zip');
// Disable caching of 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');
// Date in the pastheader('Pragma: no-cache');
// set content type:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain');
// plain text file
header('Content-Type: image/jpeg');
// JPG picture
header('Content-Type: application/zip');
// ZIP file
header('Content-Type: application/pdf');
// PDF file
header('Content-Type: audio/mpeg');
// Audio MPEG (MP3,…) file
header('Content-Type: application/x-shockwave-flash');
// Flash animation// show sign in box
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';
?>


猜你喜欢
- 问题产生描述使用子进程处理一个大的日志文件,并对文件进行分析查询,需要等待子进程执行的输出结果,进行下一步处理。出问题的代码# 启用子进程执
- Unet是一个最近比较火的网络结构。它的理论已经有很多大佬在讨论了。本文主要从实际操作的层面,讲解pytorch从头开始搭建UNet++的过
- 如下所示:ljust(len,str)字符向左对齐,用str补齐长度rjust(len,str)字符向右对齐,用str补齐长度rjust(l
- 一、安装写出许多有趣的可视化东西也可以画出很多奇妙的图案pip install turtule二、画布画布就是turtle为我们展开用于绘图
- 一、创建测试表CREATE TABLE [dbo].[Student]( [id] [int] NOT NULL,
- 代码演示暴力破解MSSQL的帐号和密码,包括管理员帐号sa的密码。网上有SQL Server Sa密码破解的存储过程,方法就是暴力破解MSS
- MybatisPlus 是一款在 Mybatis 基础上进行的增强 orm 框架,可以实现不写 sql 就完成数据库相关的操作。普通的 ma
- 我有个MM在网上面安了家,想做一个关于特效的网站。她虽然懂一点网页制作,但是她的机器配置比较低,有时为了反复试验页面上一些特殊效果,而打开D
- 运行环境:Windows 8.1Python:2.7.6在安装的时候,我使用的pip来进行安装,命令如下:pip install beaut
- 第一步:先引入所需的第三方模块import echarts from "echarts"; // 引入所需要的echar
- 一维线性拟合数据为y=4x+5加上噪音结果:import numpy as npfrom mpl_toolkits.mplot3d impo
- # -*- coding: cp936 -*-import socketfrom threading import Thread,activ
- 实例如下:</pre><pre name="code" class="python"
- 一、报错: 「Can't swap PDO instance while within transaction」通过查询 Larav
- 创建多个交易各个客户进行的交易在系统中排队;矿工从这个队列中获取交易并将其添加到块中.然后他们将挖掘区块,获胜的矿工将有权将区块添加到区块链
- 安装TensorFlow后,在Python中输入 import tensorflow as tf 时 提示一下类似错误ImportError
- 关于__dict__和dir()的区别和作用请参考这篇文章:基于Python __dict__与dir()的区别详解说下我当时遇到的问题:c
- 学习JQUERY就应该从最基本的学起,基本的就应该是语法了,在这里,我们有必要先温习一下JAVASCRIPT的一些知识。语法就不用说了,都是
- 本文实例讲述了js类的继承定义与用法。分享给大家供大家参考,具体如下:如何实现类的继承呢?有如下2个构造函数:function People
- 最近做项目的时候遇到过oracle数据库导入导出,在这里我做下记录,防止自己忘记了,有什么不对或者不足的地方,欢迎广大博友拍砖,哈哈~导出命