Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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 µÄÎļþʹÓò»°²È«µÄÊý¾Ý
ÔÙ´ÎÇ¿µ÷£º²»ÒªÏàÐŲ»ÊÇÄã×Ô¼ºÏÔʽÉùÃ÷µÄÊý¾Ý¡£²»Òª Include »ò require ´Ó$_GET, $_POST »ò $_COOKIE Öе


Ïà¹ØÎĵµ£º

PHPÖеÄereg()Óëeregi()º¯ÊýµÄ²»Í¬


ereg()
×Ö·û´®±È¶Ô½âÎö¡£
Óï·¨: int ereg(string pattern, string string, array [regs]);
·µ»ØÖµ: ÕûÊý/Êý×é
º¯ÊýÖÖÀà: ×ÊÁÏ´¦Àí
ÄÚÈÝ˵Ã÷
±¾º¯ÊýÒÔ pattern µÄ¹æÔòÀ´½âÎö±È¶Ô×Ö·û´® string¡£±È¶Ô½á¹û·µ»ØµÄÖµ·ÅÔÚÊý×é²ÎÊý regs Ö®ÖУ¬regs[0] ÄÚÈݾÍÊÇÔ­×Ö·û´® string¡¢regs[1] ΪµÚÒ»¸öºÏºõ¹æÔòµÄ×Ö·û´®¡¢regs ......

WindowsÏÂÈÃPHP³ÌÐò×Ô¶¯Ö´ÐеÄ˼·

Ö»ÊÇ˼·,»¹Ã»ÑéÖ¤. ÓÃWindowsµÄ¼Æ»®ÈÎÎñÿ¸ôÒ»¸öСʱÔËÐÐÒ»¸öphp½Å±¾. ¸Ãphp½Å±¾»á½«°ë¸öСʱºòÒªÖ´ÐеÄPHP´úÂëдÈëÒ»¸ö¹Ì¶¨µÄphpÎļþÖÐ. Óõڶþ¸ö¼Æ»®ÈÎÎñÔÚµÚÒ»¸ö¼Æ»®ÈÎÎñÖ´Ðкó°ë¸öСʱ,Ö´ÐÐÉÏÃæµÄ¹Ì¶¨µÄphpÎļþ. ʵ¼ÊÇé¿öµÈÓпÕʵÑéºóÔÙ˵. ......

PHP

ÎÒÊÇѧµç×ÓÉÌÎñµÄѧÉú£¬Ö÷Ҫѧϰ·½ÏòÊǵç×ÓÉÌÎñ¼¼Êõ²ãÃæµÄ¶«Î÷¡£Ñ§ÁËÒ»Äê¶àµÄʱ¼äÁË£¬¸Ð¾õСÓÐÊÕ»ñ¡£
Ç°¶Îʱ¼ä³öÈ¥ÃæÊÔflashµÄʱºò·¢ÏÖ×Ô¼ººÍ±ðÈ˵ÄÒªÇó²î¾àÉõÔ¶£¬»Øµ½Ñ§Ð£ºóŬÁ¦µÄѧϰPHP£¬×ÔÎҸоõ»¹²»´í£¬È«°àֻʣϼ¸¸öÈËÔÚѧºǫ́ÓïÑÔÁË£¬²»ÖªµÀÊÇÒòΪÓÐÁËÉÏÒ»´ÎµÄ´ò»÷»¹ÊÇÒòΪÎÒÊʺÏѧPHP£¬×ÔÈÏΪѧµÃ±È½Ï¿ì£¬ÖÁÉÙ±ÈÖ ......

java£¬php£¬mysqlʱ¼ä´¦Àí

javaÖÐʱ¼ä´ÁºÍʱ¼ä×Ö·û´®Ö®¼äµÄת»»
»ñÈ¡µ±Ç°µÄunixʱ¼ä´Á
new Date().getTime()
System.currentTimeMillis()
·µ»ØµÄÊǺÁÃëÊý£¬Òª×ª»»long t = System.currentTimeMillis()/1000;
»ñÈ¡µ±Ç°ÄêÔÂÈÕÒÔ¼°Ê±·ÖÃë
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR))  c.get(Calendar.YEAR))  c.get(C ......

PHPÖеÄsessionÏê½â

 
¡¡ÔÚPHP¿ª·¢ÖжԱÈÆðCookie£¬session ÊÇ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ»á»°£¬Ïà¶Ô°²È«£¬²¢ÇÒ²»Ïñ Cookie ÄÇÑùÓд洢³¤¶ÈÏÞÖÆ£¬±¾Îļòµ¥½éÉÜ session µÄʹÓá£
¡¡¡¡ÓÉÓÚ Session ÊÇÒÔÎı¾ÎļþÐÎʽ´æ´¢ÔÚ·þÎñÆ÷¶ËµÄ£¬ËùÒÔ²»Å¿ͻ§¶ËÐÞ¸Ä Session ÄÚÈÝ¡£Êµ¼ÊÉÏÔÚ·þÎñÆ÷¶ËµÄ Session Îļþ£¬PHP ×Ô¶¯ÐÞ¸Ä session ÎļþµÄȨÏÞ£¬Ö»±£Áô ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ