21¸ö¾³£Óõ½µÄPHPº¯Êý´úÂë¶Î(5)
17. PHP½âѹËõ Zip Îļþ
/********************** *@file ¨C path to zip file *@destination ¨C destination directory for unzipped files */ function unzip_file($file, $destination){ // create object $zip = new ZipArchive() ; // open archive if ($zip->open($file) !== TRUE) { die (¡¯Could not open archive¡¯); } // extract contents to destination directory $zip->extractTo($destination); // close archive $zip->close(); echo ¡®Archive extracted to directory¡¯; }
18. PHPΪ URL µØÖ·Ô¤Éè http ×Ö·û´®
ÓÐʱÐèÒª½ÓÊÜһЩ±íµ¥ÖеÄÍøÖ·ÊäÈ룬µ«Óû§ºÜÉÙÌí¼Ó http:// ×ֶΣ¬´Ë´úÂ뽫ΪÍøÖ·Ìí¼Ó¸Ã×ֶΡ£
if (!preg_match(¡°/^(http|ftp):/¡±, $_POST['url'])) { $_POST['url'] = ¡®http://¡¯.$_POST['url']; }
19. PHP½«ÍøÖ·×Ö·û´®×ª»»³É³¬¼¶Á´½Ó
¸Ãº¯Êý½« URL ºÍ E-mail µØÖ·×Ö·û´®×ª»»Îª¿Éµã»÷µÄ³¬¼¶Á´½Ó¡£
function makeClickableLinks($text) { $text = eregi_replace(¡®(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)¡¯, ¡®<a href=¡±\1¡å>\1</a>¡¯, $text); $text = eregi_replace(¡®([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)¡¯, ¡®\1<a href=¡±http://\2¡å>\2</a>¡¯, $text); $text = eregi_replace(¡®([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})¡¯, ¡®<a href=¡±mailto:\1¡å>\1</a>¡¯, $text); return $text; }
20. PHPµ÷ÕûͼÏñ³ß´ç
´´½¨Í¼ÏñËõÂÔͼÐèÒªÐí¶àʱ¼ä£¬´Ë´úÂ뽫ÓÐÖúÓÚÁ˽âËõÂÔͼµÄÂß¼¡£
/********************** *@filename ¨C path to the image *@tmpname ¨C temporary path to thumbnail *@xmax ¨C max width *@ymax ¨C max height */ function resize_image($filename, $tmpname, $xmax, $ymax) { $ext = explode(¡°.¡±, $filename); $ext = $ext[count($ext)-1]; if($ext == ¡°jpg¡± || $ext == ¡°jpeg¡±) $im = imagecreatefromjpeg($tmpname); elseif($ext == ¡°png¡±) $im = imagecreatefrompng($tmpname); elseif($ext == ¡°gif¡±) $im = imagecreatefromgif($tmpname); $x = imagesx($im); $y = imagesy($im); if($x <= $xmax && $y <= $ymax) return $im; if($x >= $y) { $newx = $xmax; $newy = $newx * $y / $x; } else { $newy = $ymax; $newx = $x / $y * $newy; } $im2 = imagecreatetruecolor($newx, $newy); imagecopyresized($im2, $im, 0, 0, 0, 0, floor($newx), floor($newy), $x, $y); return $im2; }
21. PHP¼ì²â ajax ÇëÇó
´ó¶àÊýµÄ JavaScript ¿ò¼ÜÈç jquery£¬Mootools µÈ£¬ÔÚ·¢³ö Ajax ÇëÇóʱ£¬¶¼»á·¢ËͶîÍâµÄ HTTP_X_REQUESTED_WITH Í·²¿ÐÅÏ¢£¬Í·µ±ËûÃÇÒ»¸öajaxÇëÇó£¬Òò´ËÄã¿ÉÒÔÔÚ·þÎñÆ÷¶ËÕì²âµ½ Ajax ÇëÇó¡£
if(!emptyempty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == ¡®xmlhttprequest¡¯){ //If AJAX Request Then }else{ //something else }
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ