1¡¢in_arrayµÄÓ÷¨
±ÜÃâÔÚ´óµÄÊý×éÉÏʹÓà in_array()£¬Í¬Ê±±ÜÃâÔÚÑ»·Öж԰üº¬20¸öÒÔÉÏÔªËصÄÊý×éʹÓÃÕâ¸öº¯Êý¡£ in_array()»á·Ç³£ÏûºÄ×ÊÔ´. ¶ÔÓÚСµÄÊý×éÕâÖÖÓ°Ïì¿ÉÄܺÜС£¬ µ«ÊÇÔÚÒ»¸öÑ»·Öмì²é´óÊý×é¿ÉÄÜ»áÐèÒªºÃ¼¸ÃëÖÓµÄʱ¼ä¡£ Èç¹ûÄúȷʵÐèÒªÕâ¸ö¹¦ÄÜ£¬ÇëʹÓÃisset()À´²éÕÒÊý×éÔªËØ¡£Êµ¼ÊÉÏÊÇʹÓüüÃûÀ´²éѯ¼üÖµ¡£ µ÷Óà isset($array[$var]) »á±È in_array($var, array_keys($array)) Òª¿ìµÃ¶à¡£
2¡¢Êý×é¼üÃû
ÔÚPHPÖУ¬ ʹÓò»¾µ¥ÒýºÅ°üº¬µÄ×Ö·û´®×÷ΪÊý×é¼üÃûÊǺϷ¨µÄ£¬ µ«ÊÇÎÒÃDz»Ï£ÍûÈç´Ë -- ¼üÃûÓ¦¸Ã×ÜÊÇÓɵ¥ÒýºÅ°üº¬¶ø±ÜÃâÒýÆð»ìÏý¡£ ×¢ÒâÕâÊÇʹÓÃÒ»¸ö×Ö·û´®£¬ ¶ø²»ÊÇʹÓñäÁ¿×ö¼üÃûµÄÇé¿ö¡£ÀýÈ磺
// ²»ºÃµÄд·¨
$foo = $assoc_array[blah];
// ºÃµÄд·¨
$foo = $assoc_array['blah'];
// ²»ºÃµÄд·¨
$foo = $assoc_array["$var"];
// ºÃµÄд·¨
$foo = $assoc_array[$var];
3¡¢×Ö·û´®±í´ï
ÔÚPHPÖÐÓÃÁ½ÖÖ²»Í¬µÄ·½Ê½À´±íʾһ¸ö×Ö·û´® - µ¥ÒýºÅ»òÕßË«ÒýºÅ¡£ Ö÷ÒªµÄÇø±ðÔÚÓÚÓï·¨½âÊÍÆ÷»á¶ÔË«ÒýºÅ±íʾµÄ×Ö·û´®½øÐбäÁ¿Ìæ»»£¬ ¶ø²»»á´¦Àíµ¥ÒýºÅ±íʾµÄ×Ö·û´®¡£ Òò´ËÄúÓ¦¸Ã×ÜÊÇʹÓõ¥ÒýºÅ£¬ ³ý·ÇÄúÕæµÄÐèÒªÔÚ×Ö·û´®Öд¦Àí±äÁ¿¡£ ÕâÑù£¬ ÎÒÃÇ¿ÉÒÔ¼õÉÙ³ÌÐòÔËÐÐÏûºÄ£¬ ÒòΪÓï·¨½âÊÍÆ÷²»ÐèҪÿ´Î¶à´¦ÀíÒ»´ó¶Ñ¸ù±¾Ã»ÓбäÁ¿µÄ×Ö·û´®¡£
ͬÑù£¬ Èç¹ûÄúÔÚº¯Êýµ÷ÓÃÖÐʹÓÃÁËÒ»¸ö×Ö·û´®±äÁ¿×÷Ϊ²ÎÊý£¬ Äú²»ÐèÒª½«Õâ¸ö±äÁ¿°üº¬ÔÚÒýºÅÀï¡£ Õâ»áµ¼ÖÂÓï·¨½âÊÍÆ÷¶à×öºÃ¶àÎÞÓù¦¡£ ¼Çס£¬ ¼¸ºõËùÓÐË«ÒýºÅÖеÄתÒå·û¶ÔÓÚµ¥ÒýºÅ¶¼ÊÇÎÞЧµÄ¡£ ÄúÐèÒªÁôÒâÒÔÉϵĹæÔò£¬ µ«ÊÇÓÐʱºòΪÁË´úÂëµÄ¿É¶ÁÐÔ£¬ ¿ÉÒÔÊʵ±µÄÆÆÀý¡£ ÀýÈ磺
// ²»ºÃµÄд·¨
$str = "This is a really long string with no variables for the parser to find.";
do_stuff("$str");
// ºÃµÄд·¨
$str = 'This is a really long string with no variables for the parser to find.';
do_stuff($str);
// ÓÐʱºòµ¥ÒýºÅ²»ÊÇÄÇôºÏÊÊ
$post_url = $phpbb_root_path . 'posting.' . $phpEx . '?mode=' . $mode . '&start=' . $start;<br />
// Ë«ÒýºÅÓÐʱºòÄÜÈôúÂëÐиü¼¯ÖÐ<br />
$post_url = "{$phpbb_root_path}posting.$phpEx?mode=$mode&start=$start";</p>
<p><strong>4¡¢Ñ»·¶¨ÒåÖеIJÙ×÷</strong> </p>
<p>ÔڱȽϲ¿·ÖÈç¹û´æÔÚÔËËãÇëÒ»¶¨Òª½øÐÐÓÅ»¯¡£ ÒòΪÕⲿ·Ö»áÔÚÑ»·ÖеÄÿһ²½½øÐвÙ×÷£º</p>
<p>// ÔÚÿ´ÎÑ»·ÖÐsizeofº¯Êý¶¼Òª±»µ÷ÓÃ<br />
for ($i = 0; $i < sizeof($post_data); $i++)<br />
{<br />
do_something();<br />
}<br />
// Äú¿ÉÒÔÔÚÑ»·Æðʼ²¿·Ö¶ÔÕâ¸ö²»±äµÄÁ¿¸³Öµ<br />
for ($i = 0, $size = sizeof($post_data); $i < $size; $i++)<br />
{<br />
do_something();<br />
}<br />
<br />
<br />
<strong>5¡¢·ÖÖ§Åжϣ¬switch caseºÃÓÚif else</strong> </p>
<p>ʹÓ÷ÖÖ§Óï¾äÒª±ÈÓúܶàif elseºÃºÜ¶à¡£</p>
<p><strong>6¡¢²»ÒªÀÄÓÃ@²Ù×÷·û</strong> </p>
<p>²»ÒªÀÄÓÃ@²Ù×÷·û£¬¿´ÉÏÈ¥ºÜ¼òµ¥£¬µ«Êµ¼ÊÉÏÓÃ@±È²»ÓÃ@ЧÂÊÒª²î¼¸±¶¡£ </p>
<p>Ìرð²»ÒªÔÚÑ»·ÖÐʹÓÃ@¡£</p>
<p><strong>7¡¢»ñȡʱ¼äµÄ·½·¨</strong> </p>
<p>ºÜ¶àʱºòÎÒÃÇÏ°¹ßʹÓÃtime()»ñÈ¡µ±Ç°Ê±¼ä£¬µ«time()ÖÕ¹éÊÇÒ»¸öº¯Êý£¬²»ÈçÖ±½ÓÓÃ$_SERVER['REQUEST_TIME']ºÃÒ»µã¡£
8¡¢×Ö·û´®³¤¶ÈÅжÏ
Á½ÖÖд·¨£º
£¨1£©if(strlen($str) < 5){/* do something */}
£¨2£©if(isset($str[5])){ /* do something */ }
µÚ¶þÖÖд·¨ÒªÓÅÓÚµÚÒ»ÖÖ¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿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¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ