php中使用header函数的http头设置
/ ok
header('HTTP/1.1 200 OK');
//设置一个404头:
header('HTTP/1.1 404 Not Found');
//设置地址被永久的重定向
header('HTTP/1.1 301 Moved Permanently');
//转到一个新地址
header('Location: http://www.example.org/'
);
//文件延迟转向:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';
//当然,也可以使用html语法实现
// <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');
//文档语言
header('Content-language: en');
//告诉浏览器最后一次修改时间
$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
//告诉浏览器文档内容没有发生改变
header('HTTP/1.1 304 Not Modified');
//设置内容长度
header('Content-Length: 1234');
//设置为一个下载类型
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');
// 对当前文档禁用缓存
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 past
header('Pragma: no-cache');
//设置内容类型:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); //纯文本格式
header('Content-Type: image/jpeg'); //JPG***
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音频文件
header('Content-Type: application/x-shockw**e-flash'); //Flash动画
//显示登陆对话框
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';
相关文档:
1.php数组基础:
<?php
$ary2 = "zqhung_hongzequan_zqhong";
$arr3 =explode("_",$ary2);//拆分字符串
echo $arr3[1];//打印出来的结果是hongzequan
$ary1 = array("aa","bb");
$ary1[0]="zqhung";//修改数组中的值
echo $ary1[0],"<br>";//打印出来的结果是zqhung
$ary3 = array("id"=>55);
......
from:http://www.xland.com.cn/article/7/81/0804/28778.htm
本类实现:
数据库信息导出:word,excel,json,xml,sql
数据库恢复:从sql,从文件
具体用法:
首先新建测试用数据库mytest,然后在里面建张表
PHP代码:
以下是代码片段:
--
-- 表的结构 `test`
--
CREATE TABLE `test` (
`id ......
初学PHP的时候,我们经常被PHP的绝对路径和相对路径弄的晕头转向。路径问题经常导致include及require命令不能加载到指定的页
面,从而导致Web程序运行错误。本文将跟大家一起探讨一下PHP路径问题的常用解决方案。
下面我们先做一个个简单的示例:
上图是一个简单Web项目的结构图,其中各文件的代码如下: ......
正则表达式自己一直不熟悉,这2天在网上一直看关于它的文章,自己总结了几个函数。
1.preg_match()
函数原型:int preg_match (string $pattern, string $content [, array
$matches])
preg_match
()函数在$content字符串中搜索与$pattern给出的正则表达式相匹配的内容。如果提供了$matches,则将匹配结果放入其中� ......
1、ereg里面是不需要也不能使用分隔符和修饰符的,所以ereg的功能比preg要弱上不少。
2、关于".":点在正则里面一般是除了换行符以外的全部字符,但是在ereg里面的"."是任意字符,即包括换行符!如果在preg里面希望"."
能够包括换行符,可以在修饰符中 ......