9¸ö±ØÐëÖªµÀµÄʵÓÃPHPº¯ÊýºÍ¹¦ÄÜ(4)
6¡¢Éú³ÉΨһ±êʶ·û
ijЩ³¡¾°Ï£¬¿ÉÄÜÐèÒªÉú³ÉÒ»¸öΨһµÄ×Ö·û´®¡£ÎÒ¿´µ½ºÜ¶àÈËʹÓà md5() º¯Êý£¬¼´Ê¹Ëü²¢²»ÍêÈ«Òâζ×ÅÕâ¸öÄ¿µÄ£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º // generate unique string echo md5(time() . mt_rand(1,1000000)); There is actually a PHP function named uniqid() that is meant to be used for this. // generate unique string echo uniqid(); /* prints 4bd67c947233e */ // generate another unique string echo uniqid(); /* prints 4bd67c9472340 */Äã¿ÉÄÜ»á×¢Òâµ½£¬¾¡¹Ü×Ö·û´®ÊÇΨһµÄ£¬Ç°¼¸¸ö×Ö·ûÈ´ÊÇÀàËƵģ¬ÕâÊÇÒòΪÉú³ÉµÄ×Ö·û´®Óë·þÎñÆ÷ʱ¼äÏà¹Ø¡£µ«Êµ¼ÊÉÏÒ²´æÔÚÓѺõÄÒ»·½Ã棬ÓÉÓÚÿ¸öÐÂÉú³ÉµÄ ID »á°´×Öĸ˳ÐòÅÅÁУ¬ÕâÑùÅÅÐò¾Í±äµÃºÜ¼òµ¥¡£ÎªÁ˼õÉÙÖظ´µÄ¸ÅÂÊ£¬Äã¿ÉÒÔ´«µÝÒ»¸öǰ׺£¬»òµÚ¶þ¸ö²ÎÊýÀ´Ôö¼ÓìØ£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º // with prefix echo uniqid('foo_'); /* prints foo_4bd67d6cd8b8f */ // with more entropy echo uniqid('',true); /* prints 4bd67d6cd8b926.12135106 */ // both echo uniqid('bar_',true); /* prints bar_4bd67da367b650.43684647 */
Õâ¸öº¯Êý½«²úÉú±È md5() ¸ü¶ÌµÄ×Ö·û´®£¬ÄܽÚʡһЩ¿Õ¼ä¡£
7¡¢ÐòÁл¯
ÄãÓÐûÓÐÓöµ½¹ýÐèÒªÔÚÊý¾Ý¿â»òÎı¾Îļþ´æ´¢Ò»¸ö¸´ÔÓ±äÁ¿µÄÇé¿ö£¿Äã¿ÉÄÜûÄÜÏë³öÒ»¸ö¸ñʽ»¯×Ö·û´®²¢×ª»»³ÉÊý×é»ò¶ÔÏóµÄºÃ·½·¨£¬PHP ÒѾΪÄã×¼±¸ºÃ´Ë¹¦ÄÜ¡£ÓÐÁ½ÖÖÐòÁл¯±äÁ¿µÄÁ÷Ðз½·¨¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£¬Ê¹Óà serialize() ºÍ unserialize() º¯Êý£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º // a complex array $myvar = array( 'hello', 42, array(1,'two'), 'apple' ); // convert to a string $string = serialize($myvar); echo $string; /* prints a:4:{i:0;s:5:"hello";i:1;i:42;i:2;a:2:{i:0;i:1;i:1;s:3:"two";}i:3;s:5:"apple";} */ // you can reproduce the original variable $newvar = unserialize($string); print_r($newvar); /* prints Array ( [0] => hello [1] => 42 [2] => Array ( [0] => 1 [1] => two ) [3] => apple ) */ÕâÊÇÔÉúµÄ PHP ÐòÁл¯·½·¨¡£È»¶ø£¬ÓÉÓÚ JSON ½üÄêÀ´´óÊÜ»¶Ó£¬PHP5.2 ÖÐÒѾ¼ÓÈëÁË¶Ô JSON ¸ñʽµÄÖ§³Ö¡£ÏÖÔÚÄã¿ÉÒÔʹÓà json_encode() ºÍ json_decode() º¯Êý£º
ÒÔÏÂΪÒýÓõÄÄÚÈÝ£º // a complex array $myvar = array( 'hello', 42, array(1,'two'), 'apple' ); // convert to a string $string = json_encode($myvar); echo $string; /* prints ["hello",42,[1,"two"],"apple"] */ // you can reproduce the original variable $newvar = json_decode($string); print_r($newvar); /* prints Array ( [0] => hello [1] => 42 [2] => Array ( [0] => 1 [1] => two ) [3] => apple ) */Õ⽫¸üΪÐÐÖ®ÓÐЧ£¬ÓÈÆäÓë JavaScript µÈÐí¶àÆäËûÓïÑÔ¼æÈÝ¡£È»¶ø¶ÔÓÚ¸´ÔӵĶÔÏó£¬Ä³Ð©ÐÅÏ¢¿ÉÄܻᶪʧ¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿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¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ