PHP ³£·¸µÄ 10 ¸ö´íÎó £¨×ªÔØ£©
PHPÊǸöΰ´óµÄweb¿ª·¢ÓïÑÔ£¬Áé»îµÄÓïÑÔ£¬µ«ÊÇ¿´µ½php³ÌÐòÔ±Öܶø¸´Ê¼µÄ·¸µÄһЩ´íÎó¡£ÎÒ×öÁËÏÂÃæÕâ¸öÁÐ±í£¬ÁгöÁËPHP³ÌÐòÔ±¾³£·¸µÄ10ÖдíÎ󣬴ó¶àÊýºÍ°²È«Ïà¹Ø¡£¿´¿´Äã·¸Á˼¸ÖÖ
1.²»×ªÒâhtml entities
Ò»¸ö»ù±¾µÄ³£Ê¶£ºËùÓв»¿ÉÐÅÈεÄÊäÈ루ÌرðÊÇÓû§´ÓformÖÐÌá½»µÄÊý¾Ý£© £¬Êä³ö֮ǰ¶¼Òª×ªÒâ¡£
echo $_GET['usename'] ;
Õâ¸öÀý×ÓÓпÉÄÜÊä³ö£º
<script>/*¸ü¸ÄadminÃÜÂëµÄ½Å±¾»òÉèÖÃcookieµÄ½Å±¾*/</script>
ÕâÊÇÒ»¸öÃ÷ÏԵݲȫÒþ»¼£¬³ý·ÇÄã±£Ö¤ÄãµÄÓû§¶¼ÕýÈ·µÄÊäÈë¡£
ÈçºÎÐÞ¸´ £º
ÎÒÃÇÐèÒª½«"< ",">","and" µÈת»»³ÉÕýÈ·µÄHTML±íʾ(< , >', and ")£¬º¯Êýhtmlspecialchars ºÍ htmlentities()ÕýÊǸÉÕâ¸ö»îµÄ¡£
ÕýÈ·µÄ·½·¨£º
echo htmlspecialchars($_GET['username'], ENT_QUOTES);
2. ²»×ªÒâSQLÊäÈë
ÎÒ
Ôø¾ÔÚһƪÎÄÕÂÖÐ×î¼òµ¥µÄ·ÀÖ¹sql×¢ÈëµÄ·½·¨(php+mysqlÖÐ)ÌÖÂÛ¹ýÕâ¸öÎÊÌâ²¢¸ø³öÁËÒ»¸ö¼òµ¥µÄ·½·¨
¡£ÓÐÈ˶ÔÎÒ˵£¬ËûÃÇÒѾÔÚphp.iniÖн«magic_quotesÉèÖÃΪOn£¬ËùÒÔ²»±Øµ£ÐÄÕâ¸öÎÊÌ⣬µ«ÊDz»ÊÇËùÓеÄÊäÈ붼ÊÇ´Ó$_GET,
$_POST»ò $_COOKIEÖеĵõ½µÄ£¡
ÈçºÎÐÞ¸´£º
ºÍÔÚ×î¼òµ¥µÄ·ÀÖ¹sql×¢ÈëµÄ·½·¨(php+mysqlÖÐ)ÖÐÒ»ÑùÎÒ»¹ÊÇÍƼöʹÓÃmysql_real_escape_string()º¯Êý
ÕýÈ·×ö·¨£º
<?php
$sql = "UPDATE users SET
name='.mysql_real_escape_string($name).'
WHERE id='.mysql_real_escape_string ($id).'";
mysql_query($sql);
?>
3.´íÎóµÄʹÓÃHTTP-header Ïà¹ØµÄº¯Êý: header(), session_start(), setcookie()
Óöµ½¹ýÕâ¸ö¾¯¸æÂð?"warning: Cannot add header information - headers already sent [....]
ÿ´Î´Ó·þÎñÆ÷ÏÂÔØÒ»¸öÍøÒ³µÄʱºò£¬·þÎñÆ÷µÄÊä³ö¶¼·Ö³ÉÁ½¸ö²¿·Ö£ºÍ·²¿ºÍÕýÎÄ¡£
Í·²¿°üº¬ÁËһЩ·Ç¿ÉÊÓµÄÊý¾Ý£¬ÀýÈçcookie¡£Í·²¿×ÜÊÇÏȵ½´ï¡£ÕýÎIJ¿·Ö°üÀ¨¿ÉÊÓµÄhtml£¬Í¼Æ¬µÈÊý¾Ý¡£
Èç
¹ûoutput_bufferingÉèÖÃΪOff£¬ËùÓеÄHTTP-headerÏà¹ØµÄº¯Êý±ØÐëÔÚÓÐÊä³ö֮ǰµ÷Óá£ÎÊÌâÔÚÓÚÄãÔÚÒ»¸ö»·¾³Öпª·¢£¬¶øÔÚ²¿Êð
µ½ÁíÒ»¸ö»·¾³ÖÐÈ¥µÄʱºò£¬output_bufferingµÄÉèÖÿÉÄܲ»Ò»Ñù¡£½á¹ûתÏòÍ£Ö¹ÁË£¬cookieºÍsession¶¼Ã»ÓÐÕýÈ·µÄÉè
ÖÃ........¡£
ÈçºÎÐÞ¸´:
È·±£ÔÚÊä³ö֮ǰµ÷ÓÃhttp-headerÏà¹ØµÄº¯Êý£¬²¢ÇÒÁîoutput_buffering = Off
¡£
4. Require »ò include µÄÎļþʹÓò»°²È«µÄÊý¾Ý
ÔÙ´ÎÇ¿µ÷£º²»ÒªÏàÐŲ»ÊÇÄã×Ô¼ºÏÔʽÉ
Ïà¹ØÎĵµ£º
JSON ÊÇÒ»ÏîÖ¼ÔÚÔÊÐíÖмä¼þ´´½¨Ê¹Óà JavaScript ¹ÌÓиñʽµÄ¶ÔÏóµÄÐÒé¡£Ëü×îÇ¿´óµÄÊôÐÔÊÇËüÊÇÒ»ÖÖÇáÁ¿¼¶ÐÒé¡£¼òµ¥´¦Àí RSS ¾ÛºÏ»ò recipe Áбíʱ£¬Äú²»ÐèÒªÔÚ JavaScript ÖÐʹÓà XML µÄÈ«²¿¹¦ÄÜ¡£²»ÐèÒªÑéÖ¤¸ñʽ»òÈ·±£ÑϸñµÄÊý¾Ý¼üÈë¡£
±àÂëºÍ½âÂë
ÓÐÁ½¸öº¯ÊýÓÃÓÚ JSON£ºencode ºÍ decode¡£µÚÒ»¸öº¯Êý½«°ÑÈÎÒâÀàÐ͵ÄÊý ......
ÒýÓõØÖ·£ºhttp://club.topsage.com/thread-263331-1-1.html
ѸÀ×רÁ´ PHPÊÓƵ½Ì³Ì_01µÚÒ»ÕÂÁ˽âPHP
ѸÀ×רÁ´ PHPÊÓƵ½Ì³Ì_02µÚ¶þÕÂPHPÓï·¨½á¹¹
ѸÀ×רÁ´ PHPÊÓƵ½Ì³Ì_03µÚÈýÕÂPHPº¯Êý¿â
ѸÀ×רÁ´ PHPÊÓƵ½Ì³Ì_04µÚËÄÕÂÁ˽âMySQL
ѸÀ×רÁ´ PHPÊÓƵ½Ì³Ì_ ......
Êýѧº¯Êý
Abs
º¯ÊýÃèÊö£ºmixed abs(mixed number);
·µ»ØÖµ£ºº¯Êýabs·µ»Ø²ÎÊýnumberµÄ¾ø¶ÔÖµ¡£
Acos
º¯ÊýÃèÊö£ºdouble acos(double number);
·µ»ØÖµ£ºº¯Êýacos·µ»Ø²ÎÊýnumberµÄ·´ÓàÏÒÖµ¡£Èç¹û²ÎÊýnumber´óÓÚ1»òСÓÚ1£¬
ÔòÆä·´ÓàÏÒÖµÎÞÒâÒå ¡£
Acosh --
·´Ë«ÇúÓàÏÒ
Asin
º¯ÊýÃèÊö£»double asin(double number); ......
¡¾1¡¿Ò³ÃæÖ®¼äÎÞ·¨´«µÝ±äÁ¿ get,post,sessionÔÚ×îеÄphp°æ±¾ÖÐ×Ô¶¯È«¾Ö±äÁ¿Êǹرյģ¬ËùÒÔÒª´ÓÉÏÒ»Ò³ÃæÈ¡µÃÌá½»¹ýÀ´µÃ±äÁ¿ÒªÊ¹ÓÃ$_GET['foo'],$ _POST['foo'],$_SESSION['foo']À´µÃµ½¡£µ±È»Ò²¿ÉÒÔÐÞ¸Ä×Ô¶¯È«¾Ö±äÁ¿Îª¿ª(php.ini¸ÄΪ register_globals = On)£»¿¼Âǵ½¼æÈÝÐÔ£¬»¹ÊÇÇ¿ÆÈ×Ô¼ºÊìϤеÄд·¨±È½ÏºÃ¡£¡¡¡¡
¡¾ ......
ÔÎÄÄÚÈÝ
£º
ͻ񻣼
½ÏÔçµÄʱºò£¬ÓиöÅóÓѼ«Á¦ÍƼöÎÒÈ¥¿´¿´Ò»¿îPHPÎʾíµ÷²éϵͳ¡£ÎÒËäÈ»´ÓÊÂÈí¼þÁìÓòµÄʱ¼ä
²¢²»Ì«³¤£¬µ«Ò²ÖªµÀ¹úÄÚÔÚÕâ¸öÁìÓòÑо¿ºÍ´ÓʵÄÆóÒµºÍ¸öÈ˲¢²»ÉÙ£¬Ö®Ç°Ò²¹Ø×¢¹ýºÍÆÀ¹À¹ýһЩ²úÆ·»òϵͳ£¬×ÜÌåÉÏ¿´À´£¬´ó¶àÊý²úÆ·µÄÉÌÒµ»¯³Ì¶È²»¸ß£¬ÖÊÁ¿²Î
²î²»Æ룬Àë³ÉÊìµÄÈí¼þϵͳ»¹ÓÐÏ൱һ¸ö¾àÀë¡ ......