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

PHP SESSION Ô­Àí


Ò»¡¢PHP SESSIONÔ­Àí
ÎÒÃÇÖªµÀ£¬sessionÊÇÔÚ·þÎñÆ÷¶Ë±£³ÖÓû§»á»°Êý¾ÝµÄÒ»ÖÖ·½·¨£¬¶ÔÓ¦µÄcookieÊÇÔÚ¿Í»§¶Ë±£³ÖÓû§Êý¾Ý¡£HTTPЭÒéÊÇÒ»ÖÖÎÞ״̬ЭÒ飬·þ
ÎñÆ÷ÏìÓ¦ÍêÖ®ºó¾ÍʧȥÁËÓëä¯ÀÀÆ÷µÄÁªÏµ£¬×îÔ磬Netscape½«cookieÒýÈëä¯ÀÀÆ÷£¬Ê¹µÃÊý¾Ý¿ÉÒÔ¿Í»§¶Ë¿çÒ³Ãæ½»»»£¬ÄÇô·þÎñÆ÷ÊÇÈçºÎ¼ÇסÖÚ¶àÓû§
µÄ»á»°Êý¾ÝÄØ£¿
Ê×ÏÈÒª½«¿Í»§¶ËºÍ·þÎñÆ÷¶Ë½¨Á¢Ò»Ò»ÁªÏµ£¬Ã¿¸ö¿Í»§¶Ë¶¼µÃÓÐÒ»¸öΨһ±êʶ£¬ÕâÑù·þÎñÆ÷²ÅÄÜʶ±ð³öÀ´¡£½¨ÒéΨһ±êʶµÄ·½·¨ÓÐÁ½ÖÖ£ºcookie»òÕßͨ¹ý
GET·½Ê½Ö¸¶¨¡£Ä¬ÈÏÅäÖõÄPHPʹÓÃsessionµÄʱ»á½¨Á¢Ò»¸öÃû½Ð”PHPSESSID”µÄcookie£¨¿ÉÒÔͨ¹ýphp.iniÐÞ¸Ä
session.nameÖµÖ¸¶¨£©£¬Èç¹û¿Í»§¶Ë½ûÓÃcookie,ÄãÒ²¿ÉÒÔÖ¸¶¨Í¨¹ýGET·½Ê½°Ñsession
id´«µ½·þÎñÆ÷£¨ÐÞ¸Äphp.iniÖÐsession.use_trans_sidµÈ²ÎÊý£©¡£
ÎÒÃDz鿴·þÎñÆ÷¶Ësession.save_pathĿ¼»á·¢ÏֺܶàÀàËÆsess_vv9lpgf0nmkurgvkba1vbvj915ÕâÑùµÄÎļþ£¬Õâ¸öÆäʵ¾ÍÊÇsession id “vv9lpgf0nmkurgvkba1vbvj915″¶ÔÓ¦µÄÊý¾Ý¡£
ÕæÏà¾ÍÔÚÕâÀ·þÎñÆ÷½«session id´«µÝµ½·þÎñÆ÷£¬·þÎñÆ÷¸ù¾Ýsession idÕÒµ½¶ÔÓ¦µÄÎļþ£¬¶ÁÈ¡µÄʱºò¶ÔÎļþÄÚÈݽøÐз´ÐòÁл¯¾ÍµÃµ½sessionµÄÖµ£¬±£´æµÄʱºòÏÈÐòÁл¯ÔÙдÈë¡£
ÊÂʵ¾ÍÊÇÕâÑù£¬ËùÒÔÈç¹û·þÎñÆ÷²»Ö§³Ösession»òÕßÄãÏë×Ô¶¨Òåsession£¬ÍêÈ«¿ÉÒÔDIY£¬Í¨¹ýPHPµÄuniqidÉú³ÉÓÀ²»Öظ´µÄ
session id£¬È»ºóÕÒ¸öµØ·½´æ´¢sessionµÄÄÚÈݼ´¿É£¬ÄãÒ²¿ÉÒÔѧflickr°Ñsession´æ´¢ÔÚMySQLÊý¾Ý¿âÖС£
¶þ¡¢Ê¹ÓÃsession֮ǰΪʲô±ØÐëÏÈÖ´ÐÐsession_start()£¿
Á˽âµÄÔ­ÀíÖ®ºó£¬ËùνµÄsessionÆäʵ¾ÍÊÇ¿Í»§¶ËÒ»¸ösession id·þÎñÆ÷¶ËÒ»¸ösession
file£¬Ð½¨session֮ǰִÐÐsession_start()ÊǸæËß·þÎñÆ÷ÒªÖÖÒ»¸öcookieÒÔ¼°×¼±¸ºÃsessionÎļþ£¬Òª²»È»ÄãµÄ
sessionÄÚÈÝÔõô´æ£»¶ÁÈ¡session֮ǰִÐÐsession_start()ÊǸæËß·þÎñÆ÷£¬¸Ï½ô¸ù¾Ýsession
id°ÑsessionÎļþ·´ÐòÁл¯¡£
Ö»ÓÐÒ»¸ösessionº¯Êý¿ÉÒÔÔÚsession_start()֮ǰִÐУ¬session_nam()£º¶ÁÈ¡»òÖ¸¶¨sessionÃû³Æ£¨±ÈÈçĬÈϵľÍÊÇ”PHPSESSID”£©£¬Õâ¸öµ±È»ÒªÔÚsession_start֮ǰִÐС£
Èý¡¢sessionÓ°ÏìϵͳÐÔÄÜ
sessionÔÚ´ó·ÃÎÊÁ¿ÍøÕ¾ÉÏȷʵӰÏìϵͳÐÔÄÜ£¬Ó°ÏìÐÔÄܵÄÔ­ÒòÖ®Ò»ÓÉÎļþϵͳÉè¼ÆÔì³É£¬ÔÚͬһ¸öĿ¼Ï³¬¹ý10000¸öÎļþʱ£¬ÎļþµÄ¶¨Î»½«·Ç
³£ºÄʱ£¬PHPÖ§³ÖsessionĿ¼hash£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÐÞ¸Äphp.iniÖÐsession.save_path =
“2;/path/to/session/dir”£¬ÄÇôsession½


Ïà¹ØÎĵµ£º

[PHP] User Defined Extension

Ϊ PHP Ìí¼ÓÀ©Õ¹¿âÊÇÒ»¼þ¼òµ¥µÄÊÂÇé¡£²»¹ýÊ×ÏÈÄã×îºÃ»áÒ»µãµãC/C++±à³Ì¼¼Êõ£¬²¢ÇÒ¶ÔMakefileÓÐÒ»¶¨µÄÁ˽⡣
ÒÔÏÂÊÇÔÚ Linux ϵÄÒ»¸ö¼òµ¥Àý×Ó£º
Ê×ÏÈ£¬½øÈë php Ô´´úÂëĿ¼£¨¼ÙÉèΪ PHP_SRC£¬ÒÔÏÂͬ£©£¬Ê¹Óà php ×Ô´øµÄ ext_skel ¹¤¾ßÉú³ÉÒ»¸öÐÂÀ©Õ¹ mk4php£º
cd PHP_SRC/etc;
./ext_skel --extname=mk4php
Õý³£Ç ......

PHP ÕýÔò±í´ïʽ×ÊÁÏ

¡¡Ã¿¸öPHP³ÌÐòÔ±¶¼ÖªµÀPHPÓÐÇ¿´óµÄÕýÔò±í´ïʽ¹¦ÄÜ£¬ÎªÁËÒÔºóµÄ¹¤×÷·½±ã£¬ÎÒ´ÓÍøÉÏÕûÀíÁ˹ØÓÚÕýÔò±í´ïʽµÄ×ÊÁÏ£¬·½±ãÒÔºó¹¤×÷ʱµÄ½øÐÐ×ÊÁϲéÔÄ¡£
¡¡¡¡ÕýÔò±í´ïʽ(regular expression)ÃèÊöÁËÒ»ÖÖ×Ö·û´®Æ¥ÅäµÄģʽ£¬¿ÉÒÔÓÃÀ´¼ì²éÒ»¸ö´®ÊÇ·ñº¬ÓÐijÖÖ×Ó´®¡¢½«Æ¥ÅäµÄ×Ó´®×öÌæ»»»òÕß´Óij¸ö´®ÖÐÈ¡³ö·ûºÏij¸öÌõ¼þµÄ×Ó´®µÈ¡£
¡¡¡¡ ......

php printfº¯Êý¼ò½é¼°¸ñʽ»¯¹æ¶¨·û½éÉÜ

printf()º¯ÊýÊǸñʽ»¯Êä³öº¯Êý, Ò»°ãÓÃÓÚÏò±ê×¼Êä³öÉ豸°´¹æ¶¨¸ñʽÊä³öÐÅÏ¢¡£ÔÚ±àд³ÌÐòʱ¾­³£»áÓõ½´Ëº¯Êý¡£º¯ÊýµÄÔ­ÐÍΪ£º
int printf(string $fromat [,mixed $args [,mixed ...]])
º¯Êý·µ»ØֵΪÕûÐÍ¡£Èô³É¹¦Ôò·µ»ØÊä³öµÄ×Ö·ûÊý£¬Êä³ö³ö´íÔò·µ»Ø¸ºÖµ¡£
printf()º¯ÊýµÄµ÷ÓøñʽΪ:
printf("<¸ñʽ»¯×Ö·û´®>", & ......

php½âÎöxmlʾÀý

<!-- xml ¸ñʽ
<books>
<book id='1001'>
<author>andylin</author>
<title>c language</title>
<publisher id="aaa">O'Reilly</publisher>
</book>

<book id='1002'>
<author>congfeng</author>
<t ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ