21¸ö¾³£Óõ½µÄPHPº¯Êý´úÂë¶Î
1. PHP¿ÉÔĶÁËæ»ú×Ö·û´®
´Ë´úÂ뽫´´½¨Ò»¸ö¿ÉÔĶÁµÄ×Ö·û´®£¬Ê¹Æä¸ü½Ó½ü´ÊµäÖеĵ¥´Ê£¬ÊµÓÃÇÒ¾ßÓÐÃÜÂëÑéÖ¤¹¦ÄÜ¡£
/************** *@length ¨C length of random string (must be a multiple of 2) **************/ function readable_random_string($length = 6){ $conso=array(¡°b¡±,¡±c¡±,¡±d¡±,¡±f¡±,¡±g¡±,¡±h¡±,¡±j¡±,¡±k¡±,¡±l¡±, ¡°m¡±,¡±n¡±,¡±p¡±,¡±r¡±,¡±s¡±,¡±t¡±,¡±v¡±,¡±w¡±,¡±x¡±,¡±y¡±,¡±z¡±); $vocal=array(¡°a¡±,¡±e¡±,¡±i¡±,¡±o¡±,¡±u¡±); $password=¡±"; srand ((double)microtime()*1000000); $max = $length/2; for($i=1; $i<=$max; $i++) { $password.=$conso[rand(0,19)]; $password.=$vocal[rand(0,4)]; } return $password; }
2. PHPÉú³ÉÒ»¸öËæ»ú×Ö·û´®
Èç¹û²»ÐèÒª¿ÉÔĶÁµÄ×Ö·û´®£¬Ê¹Óô˺¯ÊýÌæ´ú£¬¼´¿É´´½¨Ò»¸öËæ»ú×Ö·û´®£¬×÷ΪÓû§µÄËæ»úÃÜÂëµÈ¡£
/************* *@l ¨C length of random string */ function generate_rand($l){ $c= ¡°ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789¡å; srand((double)microtime()*1000000); for($i=0; $i<$l; $i++) { $rand.= $c[rand()%strlen($c)]; } return $rand; }
3. PHP±àÂëµç×ÓÓʼþµØÖ·
ʹÓô˴úÂ룬¿ÉÒÔ½«Èκεç×ÓÓʼþµØÖ·±àÂëΪ html ×Ö·ûʵÌ壬ÒÔ·ÀÖ¹±»À¬»øÓʼþ³ÌÐòÊÕ¼¯¡£
function encode_email($email=¡¯info@domain.com¡¯, $linkText=¡¯Contact Us¡¯, $attrs =¡¯class=¡±emailencoder¡±¡® ) { // remplazar aroba y puntos $email = str_replace(¡®@¡¯, ¡®@¡¯, $email); $email = str_replace(¡®.¡¯, ¡®.¡¯, $email); $email = str_split($email, 5); $linkText = str_replace(¡®@¡¯, ¡®@¡¯, $linkText); $linkText = str_replace(¡®.¡¯, ¡®.¡¯, $linkText); $linkText = str_split($linkText, 5); $part1 = ¡®<a href=¡±ma¡¯; $part2 = ¡®ilto:¡¯; $part3 = ¡®¡± ¡®. $attrs .¡¯ >¡¯; $part4 = ¡®</a>¡¯; $encoded = ¡®<script type=¡±text/javascript¡±>¡¯; $encoded .= ¡°[removed](¡®$part1¡ä);¡±; $encoded .= ¡°[removed](¡®$part2¡ä);¡±; foreach($email as $e) { $encoded .= ¡°[removed](¡®$e¡¯);¡±; } $encoded .= ¡°[removed](¡®$part3¡ä);¡±; foreach($linkText as $l) { $encoded .= ¡°[removed](¡®$l¡¯);¡±; } $encoded .= ¡°[removed](¡®$part4¡ä);¡±; $encoded .= ¡®</script>¡¯; return $encoded; }
4. PHPÑéÖ¤ÓʼþµØÖ·
µç×ÓÓʼþÑéÖ¤Ò²ÐíÊÇÖÐ×î³£ÓõÄÍøÒ³±íµ¥ÑéÖ¤£¬´Ë´úÂë³ýÁËÑéÖ¤µç×ÓÓʼþµØÖ·£¬Ò²¿ÉÒÔÑ¡Ôñ¼ì²éÓʼþÓòËùÊô DNS ÖÐµÄ MX ¼Ç¼£¬Ê¹ÓʼþÑéÖ¤¹¦Äܸü¼ÓÇ¿´ó¡£
function is_valid_email($email, $test_mx = false) { if(eregi(¡°^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$¡±, $email)) if($test_mx) { list($username, $domain) = split(¡°@¡±, $email); return getmxrr($domain, $mxrecords); } else return true; else return false; }5. PHPÁгöĿ¼ÄÚÈÝ
function list_files($dir) { if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != ¡°.¡± && $file != ¡°..¡± && $file != ¡°Thumbs.db¡±) { echo ¡®<a target=¡±_blank¡± href=¡±¡®.$dir.$file.¡¯¡±>¡¯.$file.¡¯</a><br>¡¯.¡±\n¡±; } } closedir($handle); } } }
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿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¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ