PHP filter_var() º¯Êý Filter º¯Êý
¶¨ÒåºÍÓ÷¨
filter_var() º¯Êýͨ¹ýÖ¸¶¨µÄ¹ýÂËÆ÷¹ýÂ˱äÁ¿¡£
Èç¹û³É¹¦£¬Ôò·µ»ØÒѹýÂ˵ÄÊý¾Ý£¬Èç¹ûʧ°Ü£¬Ôò·µ»Ø false¡£
Óï·¨
filter_var(variable, filter, options)
²ÎÊýÃèÊö
variable
±ØÐè¡£¹æ¶¨Òª¹ýÂ˵ıäÁ¿¡£
filter
¿ÉÑ¡¡£¹æ¶¨ÒªÊ¹ÓõĹýÂËÆ÷µÄ ID¡£
options
¹æ¶¨°üº¬±êÖ¾/Ñ¡ÏîµÄÊý×é¡£¼ì²éÿ¸ö¹ýÂËÆ÷¿ÉÄܵıêÖ¾ºÍÑ¡Ïî¡£
ÌáʾºÍ×¢ÊÍ
Ìáʾ£º²Î¼ûÍêÕûµÄ PHP Filter ²Î¿¼Êֲᣬ²é¿´¿ÉÓë¸Ãº¯ÊýһͬʹÓõĹýÂËÆ÷¡£
Àý×Ó
<?php
if(!filter_var("someone@example....com", FILTER_VALIDATE_EMAIL))
{
echo("E-mail is not valid");
}
else
{
echo("E-mail is valid");
}
?>
Êä³öÀàËÆ£º
E-mail is not valid
PHP Filter ¼ò½éPHP ¹ýÂËÆ÷ÓÃÓÚ¶ÔÀ´×Ô·Ç°²È«À´Ô´µÄÊý¾Ý£¨±ÈÈçÓû§ÊäÈ룩½øÐÐÑéÖ¤ºÍ¹ýÂË¡£°²×°filter º¯ÊýÊÇ PHP ºËÐĵÄ×é³É²¿·Ö¡£ÎÞÐè°²×°¼´¿ÉʹÓÃÕâЩº¯Êý¡£PHP Filter º¯ÊýPHP£ºÖ¸Ê¾Ö§³Ö¸Ãº¯ÊýµÄ×îÔçµÄ PHP °æ±¾¡£º¯ÊýÃèÊöPHPfilter_has_var()¼ì²éÊÇ·ñ´æÔÚÖ¸¶¨ÊäÈëÀàÐ͵ıäÁ¿¡£5filter_id()·µ»ØÖ¸¶¨¹ýÂËÆ÷µÄ ID ºÅ¡£5filter_input()´Ó½Å±¾Íⲿ»ñÈ¡ÊäÈ룬²¢½øÐйýÂË¡£5filter_input_array()´Ó½Å±¾Íⲿ»ñÈ¡¶àÏîÊäÈ룬²¢½øÐйýÂË¡£5filter_list()·µ»Ø°üº¬ËùÓеõ½Ö§³ÖµÄ¹ýÂËÆ÷µÄÒ»¸öÊý×é¡£5filter_var_array()»ñÈ¡¶àÏî±äÁ¿£¬²¢½øÐйýÂË¡£5filter_var()»ñÈ¡Ò»¸ö±äÁ¿£¬²¢½øÐйýÂË¡£5PHP FiltersID Ãû³ÆÃèÊöFILTER_CALLBACKµ÷ÓÃÓû§×Ô¶¨Ò庯ÊýÀ´¹ýÂËÊý¾Ý¡£FILTER_SANITIZE_STRINGÈ¥³ý±êÇ©£¬È¥³ý»ò±àÂëÌØÊâ×Ö·û¡£FILTER_SANITIZE_STRIPPED"string" ¹ýÂËÆ÷µÄ±ðÃû¡£FILTER_SANITIZE_ENCODEDURL-encode ×Ö·û´®£¬È¥³ý»ò±àÂëÌØÊâ×Ö·û¡£FILTER_SANITIZE_SPECIAL_CHARSHTML תÒå×Ö·û '"<>& ÒÔ¼° ASCII ֵСÓÚ 32 µÄ×Ö·û¡£FILTER_SANITIZE_EMAILɾ³ýËùÓÐ×Ö·û£¬³ýÁË×Öĸ¡¢Êý×ÖÒÔ¼° !#$%&'*+-/=?^_`{|}~@.[]FILTER_SANITIZE_URLɾ³ýËùÓÐ×Ö·û£¬³ýÁË×Öĸ¡¢Êý×ÖÒÔ¼° $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=FILTER_SANITIZE_NUMBER_INTɾ³ýËùÓÐ×Ö·û£¬³ýÁËÊý×ÖºÍ +-FILTER_SANITIZE_NUMBER_FLOATɾ³ýËùÓÐ×Ö·û£¬³ýÁËÊý×Ö¡¢+- ÒÔ¼° .,eE¡£FILTER_SANITIZE_MAGIC_QUOTESÓ¦Óà addslashes()¡£FILTER_UNSAFE_RAW²»½øÐÐÈκιýÂË£¬È¥³ý»ò±àÂëÌØÊâ×Ö·û¡£FILTER_VALIDATE_INTÔÚÖ¸¶¨µÄ·¶Î§ÒÔÕûÊýÑéÖ¤Öµ¡£FILTER_VALIDATE_BOOLEANÈç¹ûÊÇ "1", "true", "on" ÒÔ¼° "yes"£¬Ôò·µ»Ø true£¬Èç¹û
Ïà¹ØÎĵµ£º
PHPÓкܶàÖµµÃѧϰµÄµØ·½£¬ÕâÀïÎÒÃÇÖ÷Òª½éÉÜPHP SessionʹÓá£ÔÚPHP¿ª·¢ÖжԱÈÆðCookie£¬session ÊÇ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ»á»°£¬Ïà¶Ô°²È«£¬²¢ÇÒ²»Ïñ Cookie ÄÇÑùÓд洢³¤¶ÈÏÞÖÆ£¬ÏÂÃæÎÒÃǾͼòµ¥½éÉÜ PHP SessionʹÓá£
¡¡¡¡ÓÉÓÚ Session ÊÇÒÔÎı¾ÎļþÐÎʽ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ£¬ËùÒÔ² ......
string date ( string format [, int timestamp] ) //ÆäÖÐtimestampΪ¿ÉÑ¡£¬Ä¬ÈÏֵΪtime();
date("1"); //Monday
date("m.d.y"); //12.21.09
date("m.d.Y");//12.21.2009
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$las ......
»ù±¾¸ÅÄî
Ò»¸öÕýÔò±í´ïʽͨ³£±»³ÆΪһ¸öģʽ (pattern)£¬ÎªÓÃÀ´ÃèÊö»òÕßÆ¥ÅäһϵÁзûºÏij¸ö¾ä·¨¹æÔòµÄ×Ö·û´®¡£ÀýÈ磺Handel¡¢Händel ºÍ Haendel ÕâÈý¸ö×Ö·û´®£¬¶¼¿ÉÒÔÓÉ“H(a|ä|ae)ndel”Õâ¸öģʽÀ´ÃèÊö¡£´ó²¿·ÖÕýÔò±í´ïʽµÄÐÎʽ¶¼ÓÐÈçϵĽṹ£º
Ñ¡Ôñ| ÊúÖ±·Ö¸ô·û´ú±íÑ¡Ôñ¡£ÀýÈç“gray|grey&rd ......
×Ô¼º±àд»ùÓÚMVCµÄÇáÁ¿¼¶PHP¿ò¼Ü
2008-4-3 23:33:56 Òѱ»ÔĶÁ£º
477 ·¢±íÆÀÂÛ
×öWEB¿ª·¢ÒÑÓÐÒ»Äê,ÿ´Î¶¼Ð´Öظ´µÄ¶«Î÷, Òò´Ë,Ïë×Ô¼ºÐ´Ò»Ï¿ò¼Ü,ÒԺ󿪷¢·½±ã.
±¾ÈË֮ǰѧϰasp.NETÁ½Äê,JSP°ëÄê,¿ÉÊǺóÀ´ÒòΪ¹¤×÷µÄԹʻ»³ÉPHP.ÆäʵºÜ²»Ï²»¶PHPµÄÓï·¨.»¹ÓÐPHPµÄº¯ÊýÃû,ÿ»Ø¶¼Íü¼Ç..»¹ÊÇϲ
»¶C#ºÍJAVAµÄÓï·¨,¹þ...²» ......