phpÉú³ÉËæ»úÃÜÂëµÄ¼¸ÖÖ·½·¨(2)
·½·¨¶þ£º
1¡¢Ô¤ÖÃÒ»¸öµÄ×Ö·û´® $chars £¬°üÀ¨ a ¨C z£¬A ¨C Z£¬0 ¨C 9£¬ÒÔ¼°Ò»Ð©ÌØÊâ×Ö·û
2¡¢ÔÚ $chars ×Ö·û´®ÖÐËæ»úÈ¡Ò»¸ö×Ö·û
3¡¢Öظ´µÚ¶þ²½ n ´Î£¬¿ÉµÃ³¤¶ÈΪ n µÄÃÜÂë
function generate_password( $length = 8 ) { // ÃÜÂë×Ö·û¼¯£¬¿ÉÈÎÒâÌí¼ÓÄãÐèÒªµÄ×Ö·û $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_ []{}<>~`+=,.;:/?|'; $password = ''; for ( $i = 0; $i < $length; $i++ ) { // ÕâÀïÌṩÁ½ÖÖ×Ö·û»ñÈ¡·½Ê½ // µÚÒ»ÖÖÊÇʹÓà substr ½ØÈ¡$charsÖеÄÈÎÒâһλ×Ö·û£» // µÚ¶þÖÖÊÇÈ¡×Ö·ûÊý×é $chars µÄÈÎÒâÔªËØ // $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); $password .= $chars[ mt_rand(0, strlen($chars) - 1) ]; } $randpwd; } // µ÷Óøú¯Êý£¬´«µÝ³¤¶È²ÎÊý$pw_length = 6 echo create_password(6);
·½·¨Èý£º
1¡¢Ô¤ÖÃÒ»¸öµÄ×Ö·ûÊý×é $chars £¬°üÀ¨ a ¨C z£¬A ¨C Z£¬0 ¨C 9£¬ÒÔ¼°Ò»Ð©ÌØÊâ×Ö·û
2¡¢Í¨¹ýarray_rand()´ÓÊý×é $chars ÖÐËæ»úÑ¡³ö $length ¸öÔªËØ
3¡¢¸ù¾ÝÒÑ»ñÈ¡µÄ¼üÃûÊý×é $keys£¬´ÓÊý×é $chars È¡³ö×Ö·ûÆ´½Ó×Ö·û´®¡£¸Ã·½·¨µÄȱµãÊÇÏàͬµÄ×Ö·û²»»áÖظ´È¡¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿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¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ