ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (PHP+IIS+MsSQL±Ð¾Ç²Ä22½g) ¸ê®ÆÀx¦s»PÀɮ׺޲z ¤U½g(¹ê§@½d¨Ò)

[±Ð¾Ç] (PHP+IIS+MsSQL±Ð¾Ç²Ä22½g) ¸ê®ÆÀx¦s»PÀɮ׺޲z ¤U½g(¹ê§@½d¨Ò)

ºô­¶­p¼Æ¾¹
Sessionª«¥óªº¥Í©R¶g´Á°_©l©óPWS/IIS ¶}©l¹B§@¥B¦³¤H¶}©l³s½u®É¡C²×¤î©ó PWS/IIS Ãö³¬¡A©Î«È¤áºÝÂsÄý¾¹¥¼©ó¯S©w®É¶¡¤º¦A¦V¦øªA¾¹­n¨D¸ê°T¡A©Ò¥HSessionª«¥óª«¥ó¨Ã¤£¬O¥Ã»·¦s¦bªº¡Iªp¥B¡A¹ï©ó©Ò¦³ªº³s½uÂsÄýªÌ¦Ó¨¥¡A³£­Ó§O¾Ö¦³¤@­Ó¡y¨p¥Î¡zªº Session ª«¥ó¡A©Ò¥H¡ASessionª«¥ó¨Ã¤£¾A¦X¥Î©ó«Ø¥ß­p¼Æ¾¹¡C


Cookieª«¥ó±N¸ê°T«Ø¥ß©ó«È¤áºÝÂsÄý¾¹ªº¡A§ó¤£¾A¦X©ó­p¼Æ¾¹¡F¤ÏÆ[Àɮצ¡ªº­p¼Æ¾¹¤D§Q¥ÎÀɮתº¦s¨ú¨Ó°O¿ý­p¼Æ¸ê®Æ¡A¤]´N¬O»¡¡G§Ú­Ìªº­p¼Æ¾¹­p¦¸¸ê®Æ±N·|³QÀx¦s¦b¤@­Ó¯S©wªº¸ê®ÆÀɮפ¤¡A­p¼Æ¸ê®Æªº«O¦s¨Ã¤£·|¦]®É¶¡ªº§ïÅܦӮø¥¢¡A©Î¬O¦]¬°¦øªA¾¹¶i¦æºûÅ@¦Ó¨Ï­p¼Æ¾¹­p¦¸¸ê®Æ³QÂk¹s¡C


¬°¤F¨Ï§Ú­Ì¨¯­W²Ö¿nªºÂsÄý¤H¦¸­p¼Æ¾¹¸ê®Æ¤£¦Ü©ó¤H¶¡»]µo¡A©Ò¥H§Ú­Ì¥²¶·§Q¥ÎÀɮ׸ê®Æ³B²z¨ç¼ÆªºÀu¶Õ»P¯SÂI¡A²Î¦X¹B¥Î¨Ó³]­p§Ú­Ìªº­p¼Æ¾¹¡A¤U¨Ò§Y¬°²Î¦XÀɮ׸ê®Æ³B²z¨ç¼Æ¨Ó»s§@­p¼Æ¾¹ªºµ{¦¡ºô­¶¤º®e¡G
txtcount.php
  1. <?
  2. $countfile="count.txt";
  3. global $num;
  4. if (file_exists($countfile))
  5.    {
  6.     $file=fopen($countfile,"r");
  7.     $num=fgets($file,filesize($countfile)+1);
  8.     $num++;
  9.     fclose($file);
  10.    }
  11. else
  12.    {
  13.     $num="1";
  14.    }
  15. $file=fopen($countfile,"w");
  16. fwrite($file,$num);
  17. fclose($file);
  18. ?>

  19. <html>
  20. <head>
  21. <meta http-equiv="Content-Language" content="zh-tw">
  22. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  23. <title>²³æ¹ê¥Îªº¤å¦r­p¼Æ¾¹</title>
  24. </head>
  25. <body>
  26. <p align="center"><font size="5">²³æ¹ê¥Îªº¤å¦r­p¼Æ¾¹</font></p>
  27. <hr>
  28. <p align="center"><b><font color="#FF0000">
  29. °ÑÆ[¤H¦¸:<?=$num?></font></b></p>
  30. </body>
  31. </html>
½Æ»s¥N½X

  • µ{¦¡½X²Ä4¦æ¡G·í¤@¦³·sªºÂsÄýªÌ³sµ²¶i¤Jºô­¶¶}©lÂsÄý®É´N¥ý°õ¦æ¡yÀÉ®×ÀËÅç¡z³o¦æPHPµ{¦¡±Ô­z¡A§Q¥Îfile_exists()¨ç¼ÆÀËÅçÀɮ׬O§_¦s¦b¡A¦p¦¹¤@¨Ó¡A¥iÁקK­p¼Æ¸ê®ÆÀɤ£¦s¦b¦Ó³y¦¨µ{¦¡ªº¥¢»~¡C
  • µ{¦¡½X²Ä6~9¦æ¡G·í­p¼Æ¸ê®ÆÀɦs¦b®É¡A«h§Q¥Îfopen()¨ç¼Æ¶}±Ò­p¼Æ¸ê®ÆÀÉ¡A±µµÛ¨Ï¥Îfgets()¨ç¼Æ¨ú±o­p¦¸¦¸¼Æ¸ê®Æ¡A±NÄ~¦¸¸ê®Æ+1«á¡A´N¬O³Ì·sªº­p¦¸¦¸¼Æ¸ê®Æ¡C
  • µ{¦¡½X²Ä11~14¦æ¡G·í­p¼Æ¸ê®ÆÀɦs¦b®É¡A¥Nªíºô­¶©|¥¼¦³¤HÂsÄý¡A¦¹®ÉªºÂsÄýªÌ§Y¬°²Ä1¤H¡C
  • µ{¦¡½X²Ä15~17¦æ¡G§Q¥Îfopen()¨ç¼Æ¶}±Ò©Î«Ø¥ß¦Û°Ê­p¼Æ¸ê®ÆÀɬ°¼g¤Jª¬ºA¡A±N³Ì·sªº­p¦¸¦¸¼Æ¸ê®Æ³z¹Lfwrite()¨ç¼Æ¼g¤JÀɮפ¤«O¦s¡C




¸É¥R¡G
filesize()¨ç¼Æ¡G¨ú±oÀɮתº¤j¤p¡C
filesize()¨ç¼Æ®æ¦¡
  1. int filesize ( string filename)
½Æ»s¥N½X
­Y¦³¿ù»~µo¥Í¦^¶ÇFalse¡A§_«h¦^¶ÇÀɮפj¤p¡]bytes¡^¡C


is_readable()¨ç¼Æ¡G§PÂ_Àɮׯà§_Ū¨ú¡C
is_readable()¨ç¼Æ®æ¦¡
  1. bool is_readable ( string filename)
½Æ»s¥N½X
­YÀÉ®×¥iŪ¨ú¸ê®Æ¡]«D°ß¼g¡^¡A«h¦^¶ÇTrrue¡A§_«hFalse¡C

is_readable()¨ç¼Æ¡G§PÂ_Àɮׯà§_Ū¨ú¡C
is_writeable()¨ç¼Æ®æ¦¡
  1. bool is_writeable ( string filename)
½Æ»s¥N½X
­YÀÉ®×¥i¼g¤J¸ê®Æ¡]«D°ßŪ¡^¡A«h¦^¶ÇTrrue¡A§_«hFalse¡C
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

¹Ï§Î­p¼Æ¾¹
¤å¦r«¬­p¼Æ¾¹¬Ý°_¨Ó¦n¹³³æ½Õ¤F¤@ÂI¡A§Ú­Ì¦ó¤£±N¥¦§ï¦¨¹Ï¤ù¦¡ªº¹Ï§Î­p¼Æ¾¹¡A¤é«á¦pªG·Q´«´«¤f¨ýªº¸Ü¡Aª½±µ±N¹ÏÀÉ´«±¼´N¦æ¤F¡I


¦b¼¶¼gµ{¦¡¤§«e¡A½Ð¥ý·Ç³Æ¦n¥Nªí0~9ªº¼Æ¦r¹Ï¤ù¡AÀɦW¸ò¹Ï¤ùªº¤º®e¼Æ¦r¥²¶·¬Û²Å¡G
                  
¬°¤F±N­p¼ÆÀɮפºªº¸ê®Æ¨ú¥X¨Ó¨ÃÂà´«¬°¹Ï¤ù¡A§Ú­Ì¥²¶·±N¼Æ¦rªº¨C¤@­Ó¡u¦r¡v©î¸Ñ¥X¨Ó¡A¨Ã¥H¹Ï¤ùÀɦW´À¥N¡G
  1. <?
  2. function picout($num)
  3. {
  4. $strlen=strlen($num);
  5. for ($x=0;$x<$strlen;$x++)
  6. {
  7. $picnum=substr($num,$x,1);
  8. echo "<img src=$picnum.gif>";
  9. }
  10. }
  11. ?>
½Æ»s¥N½X

  • µ{¦¡½X²Ä4¦æ¡G¥ý§Q¥Îstrlen()¨ç¼Æ­pºâ¦r¦êªºªø«×¡]­p¼Æ¸ê®Æªº¦ì¼Æ¡^¡C
  • µ{¦¡½X²Ä5~9¦æ¡G¨Ï¥Îfor°j°é±N¦U­Ó¹Ï¤ùÀɪºHTML¼ÐÅÒ±Ô­z¿é¥X¡C
  • §Q¥Îsubstr()¨ç¼Æ©î¸Ñ¦r¦ê¡A¨C¦¸¨ú¥X¤@­Ó¦r¤¸¡C

¬°¤F¤£ÅÜ°Ê­ì©lªº¤å¦r­p¼Æ¾¹¥\¯à¡A©Ò¥H¤p»x§â¤å¦rÂà´«¦¨¹Ï¤ùHTML¼ÐÅÒ±Ô­zªºµ{¦¡°Ï¶ô¥Î¨ç¼Æ¥]°_¨Ó¡A©Ò¥H§Ú­Ì¥u­n±N¥»¨Ó¿é¥X¤å¦r¸ê®Æªº¦a¤è§ï¦¨©I¥s°Æµ{¦¡§Y¥i¡C
piccount.php
  1. <?
  2. $countfile="piccount.txt";
  3. global $num;
  4. if (file_exists($countfile))
  5.    {
  6.     $file=fopen($countfile,"r");
  7.     $num=fgets($file,filesize($countfile)+1);
  8.     $num++;
  9.     fclose($file);
  10.    }
  11. else
  12.    {
  13.     $num="1";
  14.    }
  15. $file=fopen($countfile,"w");
  16. fwrite($file,$num);
  17. fclose($file);
  18. ?>

  19. <html>
  20. <head>
  21. <meta http-equiv="Content-Language" content="zh-tw">
  22. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  23. <title>¹ê¥Îªº¹Ï¤ù­p¼Æ¾¹</title>
  24. </head>
  25. <body>
  26. <p align="center"><font size="5">¹ê¥Îªº¹Ï¤ù¦r­p¼Æ¾¹</font></p>
  27. <hr>
  28. <p align="center"><b><font color="#FF0000">
  29. °ÑÆ[¤H¦¸:<?=picout($num)?></font></b></p>
  30. </body>
  31. </html>

  32. <?
  33. function picout($num)
  34. {
  35. $strlen=strlen($num);
  36. for ($x=0;$x<$strlen;$x++)
  37.   {
  38.    $picnum=substr($num,$x,1);
  39.     echo "<img src=$picnum.gif>";
  40.   }
  41. }
  42. ?>
½Æ»s¥N½X
¥t¸Ñ¡GPiccount_2.php
  1. <?
  2. $countfile="piccount.txt";
  3. if (file_exists($countfile))
  4.    {
  5.     $file=fopen($countfile,"r");
  6.     $num=fread($file,filesize($countfile));
  7.     $num++;
  8.     fclose($file);
  9.     $file=fopen($countfile,"w");
  10.     fwrite($file,$num);
  11.     fclose($file);
  12.    }
  13. else
  14.    {
  15.     $num=1;
  16.     $file=fopen($countfile,"w");
  17.     fwrite($file,$num);
  18.     fclose($file);
  19.    }
  20. ?>

  21. <html>
  22. <head>
  23. <meta http-equiv="Content-Language" content="zh-tw">
  24. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  25. <title>¹ê¥Îªº¹Ï¤ù­p¼Æ¾¹</title>
  26. </head>
  27. <body>
  28. <p align="center"><font size="5">¹ê¥Îªº¹Ï¤ù¦r­p¼Æ¾¹</font></p>
  29. <hr>
  30. <p align="center"><b><font color="#FF0000">
  31. °ÑÆ[¤H¦¸:<?=picout()?></font></b></p>
  32. </body>
  33. </html>

  34. <?
  35. function picout()
  36. {
  37. global $countfile;
  38. $file=fopen($countfile,"r");
  39. while (false != ($char = fgetc($file)))
  40.   {
  41.      echo "<img src=" . $char . ".gif>";
  42.   }
  43. fclose($file);
  44. }
  45. ?>
½Æ»s¥N½X
¹Ï§Î­p¼Æ¾¹§¹¾ã­ì©l½X¤U¸ü:
pic_count.rar (4.95 KB)
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¤p¨Æ¤£°µ¡B¤j¨ÆÃø¦¨¡C
ªð¦^¦Cªí ¤W¤@¥DÃD