PHP ¹ýÂËÆ÷£¨Filter£©
PHP ¹ýÂËÆ÷ÓÃÓÚÑéÖ¤ºÍ¹ýÂËÀ´×Ô·Ç°²È«À´Ô´µÄÊý¾Ý£¬±ÈÈçÓû§µÄÊäÈë¡£
ʲôÊÇ PHP ¹ýÂËÆ÷£¿
PHP ¹ýÂËÆ÷ÓÃÓÚÑéÖ¤ºÍ¹ýÂËÀ´×Ô·Ç°²È«À´Ô´µÄÊý¾Ý¡£
ÑéÖ¤ºÍ¹ýÂËÓû§ÊäÈë»ò×Ô¶¨ÒåÊý¾ÝÊÇÈκΠWeb Ó¦ÓóÌÐòµÄÖØÒª×é³É²¿·Ö¡£
Éè¼Æ PHP µÄ¹ýÂËÆ÷À©Õ¹µÄÄ¿µÄÊÇʹÊý¾Ý¹ýÂ˸üÇáËÉ¿ì½Ý¡£
ΪʲôʹÓùýÂËÆ÷£¿
¼¸ºõËùÓÐ web Ó¦ÓóÌÐò¶¼ÒÀÀµÍⲿµÄÊäÈë¡£ÕâЩÊý¾Ýͨ³£À´×ÔÓû§»òÆäËûÓ¦ÓóÌÐò£¨±ÈÈç web ·þÎñ£©¡£Í¨¹ýʹÓùýÂËÆ÷£¬ÄúÄܹ»È·±£Ó¦ÓгÌÐò»ñµÃÕýÈ·µÄÊäÈëÀàÐÍ¡£
ÄúÓ¦¸ÃʼÖÕ¶ÔÍⲿÊý¾Ý½øÐйýÂË£¡
ÊäÈë¹ýÂËÊÇ×îÖØÒªµÄÓ¦ÓóÌÐò°²È«¿ÎÌâÖ®Ò»¡£
ʲôÊÇÍⲿÊý¾Ý£¿
À´×Ô±íµ¥µÄÊäÈëÊý¾Ý
Cookies
·þÎñÆ÷±äÁ¿
Êý¾Ý¿â²éѯ½á¹û
º¯ÊýºÍ¹ýÂËÆ÷
ÈçÐè¹ýÂ˱äÁ¿£¬ÇëʹÓÃÏÂÃæµÄ¹ýÂËÆ÷º¯ÊýÖ®Ò»£º
filter_var() - ͨ¹ýÒ»¸öÖ¸¶¨µÄ¹ýÂËÆ÷À´¹ýÂ˵¥Ò»µÄ±äÁ¿
filter_var_array() - ͨ¹ýÏàͬµÄ»ò²»Í¬µÄ¹ýÂËÆ÷À´¹ýÂ˶à¸ö±äÁ¿
filter_input - »ñÈ¡Ò»¸öÊäÈë±äÁ¿£¬²¢¶ÔËü½øÐйýÂË
filter_input_array - »ñÈ¡¶à¸öÊäÈë±äÁ¿£¬²¢Í¨¹ýÏàͬµÄ»ò²»Í¬µÄ¹ýÂËÆ÷¶ÔËüÃǽøÐйýÂË
ÔÚÏÂÃæµÄÀý×ÓÖУ¬ÎÒÃÇÓà filter_var() º¯ÊýÑéÖ¤ÁËÒ»¸öÕûÊý£º
<?php
$int = 123;
if(!filter_var($int, FILTER_VALIDATE_INT))
{
echo("Integer is not valid");
}
else
{
echo("Integer is valid");
}
?>
ÉÏÃæµÄ´úÂëʹÓÃÁË "FILTER_VALIDATE_INT" ¹ýÂËÆ÷À´¹ýÂ˱äÁ¿¡£ÓÉÓÚÕâ¸öÕûÊýÊǺϷ¨µÄ£¬Òò´Ë´úÂëµÄÊä³öÊÇ£º"Integer is valid"¡£
¼ÙÈçÎÒÃdz¢ÊÔʹÓÃÒ»¸ö·ÇÕûÊýµÄ±äÁ¿£¬ÔòÊä³öÊÇ£º"Integer is not valid"¡£
ÈçÐèÍêÕûµÄº¯ÊýºÍ¹ýÂËÆ÷ÁÐ±í£¬Çë·ÃÎÊÎÒÃÇµÄ PHP Filter ²Î¿¼Êֲᡣ
Validating ºÍ Sanitizing
ÓÐÁ½ÖÖ¹ýÂËÆ÷£º
Validating ¹ýÂËÆ÷£º
ÓÃÓÚÑéÖ¤Óû§ÊäÈë
ÑϸñµÄ¸ñʽ¹æÔò£¨±ÈÈç URL »ò E-Mail ÑéÖ¤£©
·µ»ØÈô³É¹¦Ô¤ÆÚµÄÀàÐÍ£¬·ñÔò·µ»Ø FALSE
Sanitizing ¹ýÂËÆ÷£º
ÓÃÓÚÔÊÐí»ò½ûÖ¹×Ö·û´®ÖÐÖ¸¶¨µÄ×Ö·û
ÎÞÊý¾Ý¸ñʽ¹æÔò
ʼÖÕ·µ»Ø×Ö·û´®
Ñ¡ÏîºÍ±êÖ¾
Ñ¡ÏîºÍ±êÖ¾ÓÃÓÚÏòÖ¸¶¨µÄ¹ýÂËÆ÷Ìí¼Ó¶îÍâµÄ¹ýÂËÑ¡Ïî¡£
²»Í¬µÄ¹ýÂËÆ÷Óв»Í¬µÄÑ¡ÏîºÍ±êÖ¾¡£
ÔÚÏÂÃæµÄÀý×ÓÖУ¬ÎÒÃÇÓà filter_var() ºÍ "min_range" ÒÔ¼° "max_range" Ñ¡ÏîÑéÖ¤ÁËÒ»¸öÕûÊý£º
<?php
$var=300;
$int_options = array(
"options"=>array
(
"min_range"=>0,
"max_range"=>256
)
);
if(!filter_var($var, FILTER_VALIDATE_INT, $int_options))
{
echo("Integer is not valid"
Ïà¹ØÎĵµ£º
Apache Httpd PHP»·¾³´î½¨
1¡¢°²×°Apache·þÎñÆ÷
2¡¢ÐÞ¸Ähttpd.conf ÖÐ ServerName localhost:9080 ºÍListen 9080
3¡¢°²×°PHP5,ÀàÐÍÑ¡ÔñApache2.*£¬Ñ¡ÔñApacheÅäÖÃÎļþĿ¼¡£
4¡¢ÐÞ¸Ähttpd.confÖÐPHP5Ôö¼ÓµÄÅäÖÃΪÈç¹ûÄÚÈÝ£º
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
& ......
ÉùÃ÷£¬ÎÒÓõÄPHP¿ò¼ÜÊÇCI£¨codeignitor)£¬µ«ÆäʵÒòΪÊÇÓÃJSµ÷ÓÃFCKeditorµÄ£¬ËùÒÔÕâ¸öºÍ¿ò¼ÜûÓйØϵ
Ê×ÏÈÏÂÔØFCKeditor 2.6.3 £¨ÎÒʹÓõÄÊÇÕâ¸ö°æ±¾£©
¿ÉÒÔÔÚCSDNÖÐÏÂÔØ
½âѹ£¬½«FCKeditor2.6.3ÏÂÃæµÄfckeditorÕû¸öÎļþ¼Ð¸´ÖƵ½ÍøÕ¾¸ùĿ¼(ºÍindex.php£©Í¬Ò»¸öĿ¼£¬²¢¸üÃûΪfck£¨²»¸ÄÃûÒ²ÐУ¬µ«ºóÃæÉèÖøù·¾¶µÄʱºò ......
$_POST ±äÁ¿ÓÃÓÚÊÕ¼¯À´×Ô method="post" µÄ±íµ¥ÖеÄÖµ¡£
$_POST ±äÁ¿
$_POST ±äÁ¿ÊÇÒ»¸öÊý×飬ÄÚÈÝÊÇÓÉ HTTP POST ·½·¨·¢Ë͵ıäÁ¿Ãû³ÆºÍÖµ¡£
$_POST ±äÁ¿ÓÃÓÚÊÕ¼¯À´×Ô method="post" µÄ±íµ¥ÖеÄÖµ¡£´Ó´øÓÐ POST ·½·¨µÄ±íµ¥·¢Ë͵ÄÐÅÏ¢£¬¶ÔÈκÎÈ˶¼ÊDz»¿É¼ûµÄ£¨²»»áÏÔʾÔÚä¯ÀÀÆ÷µÄµØÖ·À¸£©£¬²¢ÇÒ¶Ô·¢ËÍÐÅÏ¢µÄÁ¿Ò²Ã»ÓÐÏÞÖ ......
ÔÚ PHP ÖУ¬Ä¬ÈϵĴíÎó´¦ÀíºÜ¼òµ¥¡£Ò»ÌõÏûÏ¢»á±»·¢Ë͵½ä¯ÀÀÆ÷£¬ÕâÌõÏûÏ¢´øÓÐÎļþÃû¡¢ÐкÅÒÔ¼°Ò»ÌõÃèÊö´íÎóµÄÏûÏ¢¡£
PHP ´íÎó´¦Àí
ÔÚ´´½¨½Å±¾ºÍ web Ó¦ÓóÌÐòʱ£¬´íÎó´¦ÀíÊÇÒ»¸öÖØÒªµÄ²¿·Ö¡£Èç¹ûÄúµÄ´úÂëȱÉÙ´íÎó¼ì²â±àÂ룬ÄÇô³ÌÐò¿´ÉÏÈ¥ºÜ²»×¨Òµ£¬Ò²Îª°²È«·çÏÕ³¨¿ªÁË´óÃÅ¡£
±¾½Ì³Ì½éÉÜÁË PHP ÖÐһЩ×îΪÖØÒªµÄ´íÎó¼ì² ......