PHPÏÂeregʵÏÖÆ¥ÅäipµÄÕýÔò
$ip = "1.1.1.255".chr(0)."haha";
if(ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$",$ip)) {
echo $ip;
} else {
echo "unknown";
}
Õâ¸öeregÕýÔòÏÞÖÆÁË$ipµÄÊý¾ÝΪxxx.xxx.xxx.xxxÕâÑùµÄÐÎʽ£¬±íÃæÉÏ¿´ÉÏÃæµÄ´úÂëÓ¦¸ÃÊä³ö"unknown"£¬¶øÊµ¼ÊÈ´Êä³öÁË"1.1.1.255haha"£¬ÒòΪeregº¯Êý´æÔÚNULL½Ø¶Ï©¶´£¬µ¼ÖÂÁËÕýÔò¹ýÂ˱»Èƹý¡£4 \2 n+ Y6 |; Z7 O
6 e& b6 C5 F- W- F$ zÎÒÃÇÔÚÀûÓÃʱ±ØÐëÒªÒýÈë\x00(%00)£¬¶øÔÚGPCΪONµÄÇé¿öÏÂ%00»á±»×ªÒåµ¼ÖÂÎÞ·¨ÀûÓᣵ«ÊÇÈç¹û±»ereg()´¦ÀíµÄÊÇ$ _SERVER(ÔÚPHP5Ï¿ÉÒÔÈÆ¹ýGPC£©»òÊDZ»urldecodeÕâÑùµÄº¯Êý´¦Àíµ¼ÖÂGPC±»ÈƹýµÄÊý¾ÝÄØ£¿±ÈÈçÓÐЩ³ÌÐò¾ÍÓÃÉÏÃæµÄ·½·¨ÑéÖ¤$ _SERVERÌá½»ÉÏÀ´µÄIP£¬ÄÇôÎÒÃǾͿÉÒÔÀûÓÃNULL½Ø¶ÏÈÆ¹ýÕýÔò¹ýÂËÀ´¹¹ÔìÎÒÃÇÐèÒªµÄÊý¾ÝÁË£º£©
Ïà¹ØÎĵµ£º
½«Ò»¸ö1άÊý×é·Ö¸î³É2άÊý×é array_chunk()
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));
±È½Ï2¸öÊý×飬array_diff_assoc£¨£©»òÕßarray_diff£¨£©£¬Èç¹û·µ»ØÖµÎª¿Õ£¬±íʾÁ½¸öÊý×éÏàͬ£¬·ñÔò¾Í²»Í¬¡£
ÓÃÒ»¸öº¯ÊýÀ´¹ýÂËÊý×éÖеÄÊýÖµarray_filter()
functi ......
ÎÊÌ⣺
ÄãÏë´´½¨Ò»¸ö¶ÔÏ󣬲¢ÔÚÆäÖÐÌí¼ÓһЩÊôÐÔ£¬µ«ÊÇÄãÈ´²»Ïë°ÑËü×÷Ϊһ¸öÃ÷È·µÄÀàÕýʽµØ¶¨ÒåËü¡£ÕâÒ»µãÔÚһЩÇé¿öÏÂÊÇÏ൱ÓÐÓõģ¬ÀýÈçµ±ÄãÐèÒª¶¨ÒåÒ»¸ö·½·¨À´·µ»Ø´øÓÐijЩÊôÐÔ£¨²»È·¶¨µÄ£©µÄ¶ÔÏóʱ£¬¾ÍÈçͬ´Ómysql_fetch_object( ) »òÕß imap_header( )µÄʹÓÃÒ»Ñù¡£
һάÊý×é,ÎÒÏÖÔÚÌØ±ðϲ»¶°ÑËüд³É¶ÔÏó,ÒòΪ¼üÅÌ´ ......
<?php
function toFixLen($str,$len){ //¹Ì¶¨³¤¶È×Ö·û´®µÄ½ØÈ¡
if($len>=strlen($str)||!$len) return $str;
$len-=3;
  ......
ÈçºÎ²»Ê¹ÓÃprepared statment£¬¶øÊÇÓùýÂ˵ķ½·¨±ÜÃâSQL×¢ÈëÄØ£¿
Ò»°ãÀ´Ëµmysql×Ô´øµÄ¹ýÂ˺¯ÊýÊDZȽϿɿ¿µÄ¡£mysql_real_escape_string()
µ«ÊÇÕâ¸öº¯ÊýÔÚijЩ×Ö·û¼¯ÖÐÓÐÎÊÌ⣬±ÈÈçGBK¡£Èç¹ûÄãÓÃUTF8ÄÇû¹ØÏµ¡£
ÔÚPHPÀïÉèÖÃÊý¾Ý¿âµÄ×Ö·û¼¯²»Ó¦¸ÃÓãºmysql_query("SET NAMES UTF8");
¶øÓ¦¸ÃÓãºmysql_set_charset()
ÕâÑù ......