php(gd¿â£©Êä³öÖÐÎÄͼÏñµÄת»»º¯Êý
http://linux.sheup.com/linux/linux4646.htm
GB2312->UTF-8 ת»»º¯Êý
ÒÔÏÂÊÇÒ»¶Îgb2312 -> UTF-8 µÄº¯Êý£¬Î÷Î÷£¬ÎÒ³ÁË
unicode -> UTF-8 µÄËã·¨£¬ËùÒÔʵ¼Ê±ÈGB2312->unicode
û¶à¶àÉÙ¶«Î÷,Çë´ó¼Ò×¢Òâµ÷ÓÃgb2utf8()ʱ²»ÄÜÖÐÓ¢ÎÄ»ìÓÃ
³ÌÐòÐèÒªµÄGB2312.txtÎļþ
gb2utf8.php
//Program writen by sadly www.phpx.com
function gb2utf8($gb)
{
if(!trim($gb))
return $gb;
$filename="gb2312.txt";
$tmp=file($filename);
$codetable=array();
while(list($key,$value)=each($tmp))
$codetable[hexdec(substr($value,0,6))]=substr($value,7,6);
$utf8="";
while($gb)
{
if (ord(substr($gb,0,1))>127)
{
$this=substr($gb,0,2);
$gb=substr($gb,2,strlen($gb));
$utf8.=u2utf8(hexdec($codetable[hexdec(bin2hex($this))-0x8080]));
}
else
{
$gb=substr($gb,1,strlen($gb));
$utf8.=u2utf8(substr($gb,0,1));
}
}
$ret="";
for($i=0;$i $ret.=chr(substr($utf8,$i,3));
return $ret;
}
function u2utf8($c)
{
for($i=0;$i $str="";
if ($c < 0x80) {
$str.=$c;
}
else if ($c < 0x800) {
$str.=(0xC0 | $c>>6);
$str.=(0x80 | $c & 0x3F);
}
else if ($c < 0x10000) {
$str.=(0xE0 | $c>>12);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
else if ($c < 0x200000) {
$str.=(0xF0 | $c>>18);
$str.=(0x80 | $c>>12 & 0x3F);
$str.=(0x80 | $c>>6 & 0x3F);
$str.=(0x80 | $c & 0x3F);
}
return $str;
}
?>
µ÷ÓþÙÀý:ͨ¹ýGDÊä³ö "Öйú" Á½¸öºº×Ö
example.php
//Header("Content-type: image/gif");
$im = imagecreate(400,300);
$bkg = ImageColorAllocate($im, 0,0,0);
$clr = ImageColorAllocate($im, 255,255,255);
$fnt = "d:/winnt/fonts/simhei.ttf";
include("gb2utf8.php");
$str = gb2utf8("Öйú");
ImageTTFText($im, 20, 0, 10, 20, $clr, $fnt, $str);
ImageGif($im);
ImageDestroy($im);
?>
Ïà¹ØÎĵµ£º
ÔÚPHP¿ª·¢ÖÐ¶Ô±ÈÆðCookie£¬session ÊÇ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ»á»°£¬Ïà¶Ô°²È«£¬²¢ÇÒ²»Ïñ Cookie ÄÇÑùÓд洢³¤¶ÈÏÞÖÆ£¬±¾Îļòµ¥½éÉÜ session µÄʹÓá£
¡¡¡¡ÓÉÓÚ Session ÊÇÒÔÎı¾ÎļþÐÎʽ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ£¬ËùÒÔ²»Å¿ͻ§¶ËÐÞ¸Ä Session ÄÚÈÝ¡£Êµ¼ÊÉÏÔÚ·þÎñÆ÷¶ËµÄ Session Îļþ£¬PHP ×Ô¶¯ÐÞ¸Ä session ÎļþµÄȨÏÞ£¬Ö»±£ÁôÁËϵͳ¶ÁºÍ ......
Óà PHP ¿ØÖÆä¯ÀÀÆ÷»º´æÊǷdz£ÈÝÒ׵ģ¬ÊÖ²áÉÏÒ²Ïà¹ØµÄ˵Ã÷£¬ÓÉÓںܶà³õѧÕßûÓаÑÊֲῴÍ꣬ËùÒÔ»¹ÊÇ»áÓÐºÜ¶à¹ØÓÚÕâ¸öÎÊÌâµÄÒÉÎÊ£¬¹ÊÔÚ´ËרÃÅ·¢Ò»ÆªÎÄÕ£¬Í¬Ê±¶ÔÏà¹ØµÄÓï·¨×öÁËÏêϸµÄ˵Ã÷£¬·½±ãÐÂÊÖ²éÔÄ¡£
¡¡¡¡Òª½â¾öÕâÒ»ÎÊÌ⣬¿ÉÒÔͨ¹ý PHP ÖÐµÄ header() º¯Êý£¬·¢ËÍÌØ¶¨µÄ»º´æ¿ØÖÆÔʼ HTTP ±êÍ·£¬¾ßÌå´úÂëÈçÏ£º
Exampl ......
<?php
//µ÷ÊÔÊä³öÐÅÏ¢
$pageCount=15;
for($i=1;$i<=$pageCount;$i++){
dump(GetPageRange($i,$pageCount),$i);
}
//$currentPage µ±Ç°Ò³Âë
//$pageCount ×ÜÒ³Êý
//$leftSize ×ó²àÒ³Â뷶Χ
//$rightSize ÓÒ²àÒ³Â뷶Χ
//·µ»ØÒ³ÂëÇø¼äÊý×é
function GetPageRange($currentPage,$pageCount,$leftSize=3, ......
4.1 ¿é×¢ÊÍ
¿é×¢ÊÍͨ³£ÓÃÓÚÌṩ¶ÔÎļþ£¬·½·¨£¬Êý¾Ý½á¹¹ºÍËã·¨µÄÃèÊö¡£¿é×¢Êͱ»ÖÃÓÚÿ¸öÎļþµÄ¿ªÊ¼´¦ÒÔ¼°Ã¿¸ö·½·¨Ö®Ç°¡£ËüÃÇÒ²¿ÉÒÔ±»ÓÃÓÚÆäËûµØ·½£¬±ÈÈç·½·¨ÄÚ²¿¡£ÔÚ¹¦Äܺͷ½·¨ÄÚ²¿µÄ¿é×¢ÊÍÓ¦¸ÃºÍËüÃÇËùÃèÊöµÄ´úÂë¾ßÓÐÒ»ÑùµÄËõ½ø¸ñʽ¡£
¿é×¢ÊÍÖ®Ê×Ó¦¸ÃÓÐÒ»¸ö¿ÕÐУ¬ÓÃÓÚ°Ñ¿é×¢ÊͺʹúÂë·Ö¸î¿ªÀ´£¬±ÈÈ磺
/*
* ÕâÀïÊÇ¿é×¢ÊÍ ......
ÑéÖ¤ÂëµÄ´óÖÂÔÀíÊÇÕâÑùµÄ£¬Ê×ÏÈÉú³ÉÒ»¸öËæ»úÊý£¬È»ºóÔÚÊý¾ÝÊýÉÏÃæ¼ÓÉϸÉÈÅͼƬ£¬Í¬Ê±°Ñ¸ÃÊý¾ÝÉú³ÉͼƬ²¢Êä³ö¡£
Õâ¸öÊý¾Ý±£´æÔÚsessionÖС£È»ºó°ÑÓû§µÄÊäÈëÓë±£´æÔÚsessionÖеÄÊý¾Ý½øÐÐÆ¥Å䣬½øÐÐÑéÖ¤¡£
verifyCode.php´úÂëÈçÏ£º
<?php
Header("Content-type: image/PNG");
session_start();
//× ......