PHP header() examples ÍêÕû´úÂë
/*** Function: PHP header() examples (PHP)
**
Desc: Some examples on how to use the header() function of PHPYou find
a detailed tutorial at expertsrt.com (English) or at ffm.junetz.de
(German).These is also a good help about caching at web-caching.com.
**
Example: see below.
<br/><br/><b>Tip:</b>
You can use these sites to check your headers: <a
href="http://web-sniffer.net/">web-sniffer.net</a>,
<a
href="http://www.delorie.com/web/headers.html">delorie.com</a>
or <a
href="http://www.forret.com/projects/analyze/">www.forret.com</a>.
** Author: Jonas John
*/
// 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"');
Ïà¹ØÎĵµ£º
1 ÔÚSQLÓï¾äÖпÉͨ¹ýÌí¼ÓÏÞÖÆÌõ¼þ:left(text,20)ֻȡtextÎı¾µÄǰ20¸ö×Ö;
¡¡¡¡2 ¿ÉÒÔÓÃlimit fromRecord, RecordNum À´×÷Ϊ·ÖҳʹÓÃ,±ÈÈçlimit 0,30±íʾ´ÓµÚÒ»¸ö¼Ç¼¿ªÊ¼±éÀú30¸ö¼Í¼;
¡¡¡¡3 Á½¸ö±íµÄÁ¬½Ó¿ÉÒÔÊÇ£ºtable1 join table2 using x(xΪÁ½¸ö±íµÄ¹«¹²×Ö¶Î),»òÕßÊÇtable1 join table2 on table1.x = table2.x
¡¡¡ ......
Ò»¡¢ ÒýÑÔ
¡¡¡¡PHPÊÇÒ»ÖÖÁ¦Á¿Ç¿´óµ«Ï൱ÈÝÒ×ѧϰµÄ·þÎñÆ÷¶Ë½Å±¾ÓïÑÔ£¬¼´Ê¹ÊǾÑé²»¶àµÄ³ÌÐòÔ±Ò²Äܹ»Ê¹ÓÃËüÀ´´´½¨¸´ÔӵĶ¯Ì¬µÄwebÕ¾µã¡£È»¶ø£¬ËüÔÚʵÏÖÒòÌØÍø·þÎñµÄÃØÃܺͰ²È«·½ÃæÈ´³£³£´æÔÚÐí¶àÀ§ÄÑ¡£ÔÚ±¾ÏµÁÐÎÄÕÂÖУ¬ÎÒÃǽ«Ïò¶ÁÕß½éÉܽøÐÐweb¿ª·¢Ëù±ØÐèµÄ°²È«±³¾°ÒÔ¼°PHPÌØ¶¨µÄ֪ʶºÍ´úÂë-Äã¿ÉÒÔ½èÒÔ±£»¤Äã×Ô¼ºµÄwebÓ¦Óó ......
<?php
/* ----------------------------------------------------------------------------
* Script Name: encrypt.php
* Creation Date: 2008-4-7 10:36
* Last Modified: 2008-4-12 16:00
* Author: meyu
* Copyright (c) 2007
* Purpose: Êý×Ö×Ö·û´®¼òÒ×¼Ó½âÃÜ
* --------------------------------- ......
×î½üдһ¸ö¹ØÓÚ¶ÁÈ¡ÖÐÎÄÎļþÃûµÄСCASEÖÐÓöµ½Á˲»PHP²»Ö§³ÖÖÐÎÄÎļþÃûµÄÎÊÌâ
ÎҵĻ·¾³£º
WINDOWS+Appach +mysql
phpÒ³ MYSQL¾ùΪ±àÂëUTF-8
½â¾ö·½·¨ÈçÏ£º
ÔÚMYSQLÖÐÈ¡³öµÄÖÐÎÄÎļþÃûת»»Æä±àÂë
$fileName=iconv("UTF-8","GBK",$fileName); ......
×÷Ϊһ¸ö×ÊÉî²¢ÇÒרҵµÄ°ÇƤÈËÔ±£¬ÔÚÎÒ´Ó³õÈý¿ªÊ¼Í¶Èëΰ´óµÄ»¥ÁªÍøÖе½ÏÖÔÚ»ýÀÛÁ˷ḻµÄ°ÇƤ¾Ñé¡£ÎÒÏàÐÅÿ¸ö×öwebµÄ³ÌÐòÔ±Ò²¶¼»áÓÐÀàËÆµÄ¾Àú¡£
ÔÚ°ÇÆ¤¹ý³ÌÖУ¬±Ø²»¿ÉÉÙµÄÐèÒªÏÂÔØÑùʽÎļþÖеÄͼƬ¡£Åöµ½±È½ÏÅÓ´óµÄÑùʽÎļþ£¬ÆäÖпÉÄÜ»áÓÐÉϰٸöÐèÒªÏÂÔØµÄͼƬ£¬ÄÇôʹÓÃÏÂÃæÕâ¶ÎС´úÂëÊÇ×îΪºÏ
ÊʵÄÁË¡£
< ?php
/* ......