Php²É¼¯ÈÃÄãµÄÕ¾¸úÐÂÀËÍøµÄÐÂÎű£³Öͬ²½.doc
²É¼¯ÒѾ²»ÊÇʲôÐÂÃû´ÊÁË,ºÜ¶àÕ¾³¤ÎªÁËÊ¡ÊÂ,Ò²¾ÖÏÞÓÚÈËÁ¦µÄȱ·¦,ʹÓóÌÐòÀ´¸ø×Ô¼º
µÄÍøÕ¾Ìíש¼ÓÍß,±ÈÈç±¾È˵ĸöÈËÍøÕ¾Î÷Î÷¸¥Ë¹ÍøÒ²²É¼¯ÁË´óÁ¿µÄÐÂÎÅ,ÄÇôÈç¹ûʵÏÖÄØ?½ñÌìÎÒÃÇÔËÓÃphpÀ´ÊµÏÖÕâ¸ö¹¦ÄÜ.
̸µ½²É¼¯,ÎÒÃDz»µÃ²»ËµÁ½¸ö¶«Î÷,µÚÒ»¸öÊÇÈçºÎ»ñÈ¡Ô¶³ÌÍøÕ¾µÄÔ´´úÂë,Õâ¸ö¿ÉÒÔͨ¹ýphpµÄÒ»¸öÀ©Õ¹curlÀ´»ñÈ¡,ÁíÒ»¸öÊÇÈç¹ûȥƥÅäÄãÐèÒªµÄÐÅÏ¢,Õâ¸öµÄ½â¾ö°ì·¨ÊÇÕýÔò±í´ïʽ.
WindowsÏ¿ªÆôcurlµÄ·½·¨ÈçÏÂ:
1¡¢¿½±´PHPĿ¼ÖеÄlibeay32.dll, ssleay32.dll, php5ts.dll, php_curl.dllÎļþµ½ system32 Ŀ¼¡£
2¡¢ÐÞ¸Äphp.ini£ºÅäÖúà extension_dir £¬È¥µô extension = php_curl.dll Ç°ÃæµÄ·ÖºÅ¡£
3¡¢ÖØÆðapache¡£
LinuxÏ¿ªÆôcurlµÄ·½·¨ÈçÏÂ:
½øÈë°²×° Ôphp µÄÔ´ÂëĿ¼£¬
cd ext
cd curl
phpize
./configure --with-curl =DIR
make
¾Í»áÔÚPHPDIR/ext/curl /moudles/ÏÂÉú³Écurl .soµÄÎļþ¡£
¸´ÖÆcurl .soÎļþµ½extensionsµÄÅäÖÃĿ¼£¬ÐÞ¸Äphp .ini¾ÍºÃÁË.
È»ºóÄã¾Í¿ÉÒÔÀûÓÃcurlÀ´»ñÈ¡µ½Ö¸¶¨urlµÄÍøÒ³Ô´ÂëÁË,ÕâÀï¸ø´ó¼ÒÒ»¸ö·â×°ºÃµÄº¯Êý:
function getwebcontent($url){
$ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
$contents = trim(curl_exec($ch));
curl_close($ch);
return $contents;
}
½ÓÏÂÀ´¾ÍÓ¦¸Ã˵µ½phpÖеÄÕýÔò±í´ïʽÁË:
1.ÖÐÀ¨ºÅ
[0-9]Æ¥Åä0-9
[a-z]Æ¥Åäa-zСд×Öĸ
[A-Z]Æ¥ÅäA-Z´óд×Öĸ
[a-zA-Z]Æ¥ÅäËùÓдóСд×Öĸ
¿ÉÒÔʹÓÃasciiÀ´Öƶ¨¸ü¶à
2.Á¿´Ê
p+Æ¥ÅäÖÁÉÙÒ»¸öº¬pµÄ×Ö·û´®
p*ÅãÅãÈκΰüº¬0¸ö»ò¶à¸öpµÄ×Ö·û´®
p?Æ¥ÅäÈκΰüº¬0¸ö»òÒ»¸öpµÄ×Ö·û´®
p{2}Æ¥Åä°üº¬2¸öpµÄÐòÁеÄ×Ö·û´®
p{2,3}Æ¥ÅäÈκΰüº¬2¸ö»ò3¸öµÄ×Ö·û´®
Ïà¹ØÎĵµ£º
»ùÓÚPHPµÄÍøÉÏÉ̳ǹÜÀíÐÅϢϵͳ·ÖÎöÓëÉè¼Æ
Ò»¡¢ (±³¾°½éÉÜ)Ñ¡ÌâÒÀ¾Ý¼°¼ÛÖµ£º
2008ÄêÏ°ëÄê,È«ÇòÐԵĽðÈÚΣ»ú±¬·¢,ÂûÑÓÖÁ¸÷¸ö²úÒµ¼°ÁìÓò,Õâ´Î¾¼ÃµÄ´óÏôÌõÈÃÎÒ¿´µ½µÄÊÇ»úÓö,ÖйúÔÚÕâ´Î¾¼ÃΣ»úÖÐÏÔʾÁ˲»·²µÄʵÁ¦Ó뷢չDZÁ¦,µ±ÆóÒµÃæÁÙÀ§¾³µÄʱºò,×îÏÈÏëµ½µÄÊÇÈçºÎËõ¼õÉÌÒµ³É±¾,±ÈÈç²ÃÔ±½µÐ½,Ëæ×ÅÍøÂç ......
Ò»¡¢Ê²Ã´ÊÇÊý×é
Êý×é¾ÍÊÇÒ»×éÊý¾ÝµÄ¼¯ºÏ£¬°ÑһϵÁÐÊý¾Ý×éÖ¯ÆðÀ´£¬ÐγÉÒ»¸ö¿É²Ù×÷µÄÕûÌå¡£Êý×éµÄÿ¸öʵÌ嶼°üº¬Á½Ï¼üºÍÖµ¡£
¶þ¡¢ÉùÃ÷Êý¾Ý
ÔÚPHPÖÐÉùÃ÷Êý×éµÄ·½Ê½Ö÷ÒªÓÐÁ½ÖÖ£ºÒ»ÊÇÓ¦ÓÃarray()º¯ÊýÉùÃ÷Êý×飬һÊÇÖ±½ÓΪÊý×éÔªËظ³Öµ¡£
<1>array()º¯ÊýÉùÃ÷µÄÊý×éµÄ·½Ê½array([mixed...]) ²ÎÊýmixedµÄÓ﷨Π......
ƽʱÓà htmlspecialchars() À´¹ýÂËhtml, µ«ÊÇ°ÑhtmlµÄ×Ö·ûתÒåÁË,×îºóÏÔʾ³öÀ´µÄ¾ÍÊÇhtmlÔ´´úÂë, ÀûÓÃstrip_tags()¾Í¿ÉÒÔ°Ñhtml±êÇ©È¥³ýµô.
[php]
$str = 'harryxu
‘;
echo(htmlspecialchars($str) . ‘
‘);
echo(strip_tags($str));
// output:
// harryxu
// harryxu
?>
......
Èç¹ûËùÓеÄClass¶¼Ó¦¸Ã´æÔÚÓÚÒ»¸öĬÈϵIJ㼶ÖеĻ°£¬ÄÇô×²ãÓ¦¸ÃÊÇ×îΪһ°ãµÄClass£¬Ò²¾ÍÊÇ˵¼«Îª³éÏóµÄ£¬Ã¿Ò»¸öϲãµÄClass¾ù±ÈÆäÉϲã
µÄClass£¨¼´¸¸Àࣩ¸ü¼ÓרÃÅ»¯¡£»ùÓÚ¸Ã˼Ï룬ÔÚPHPÖУ¬Õâ¸ö¶¥²ãµÄClass±»ÃüÃûΪ“stdClass”£¬ÇÒ×÷Ϊһ¸ö“Standard
Class”£¬Äã¿ÉÒÔ°ÑËü¿´³ÉÊÇÒ ......
·þÎñÆ÷±äÁ¿ $_SERVER Ïê½â£º
1¡¢$_SESSION['PHP_SELF'] -- »ñÈ¡µ±Ç°ÕýÔÚÖ´Ðнű¾µÄÎļþÃû
2¡¢$_SERVER['SERVER_PROTOCOL'] -- ÇëÇóÒ³ÃæʱͨÐÅÐÒéµÄÃû³ÆºÍ°æ±¾¡£ÀýÈ磬“HTTP/1.0”¡£
3¡¢$_SERVER['REQUEST_TIME'] -- ÇëÇó¿ªÊ¼Ê±µÄʱ¼ä´Á¡£´Ó PHP 5.1.0 ÆðÓÐЧ¡£ºÍtimeº¯ÊýЧ¹ûÒ»Ñù¡£
4¡¢$_SERVER['a ......