Re: [請益] PHP計數器問題

看板PHP作者 (我愛胖子)時間15年前 (2010/07/22 15:26), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
<? //按下後,文字檔案內容值加1 function filecount{$file_name){ $fd=fopen($file_name,"r"); if($fd){ $counter=fgets($fd,80); $counter=doubleval($counter)+1; fseek($fd,0); fputs($fd,$counter); } fclose($fd); return $counter; } //定義讀取文字檔案內容 function readcounter($file_name){ $handle=fopen($file_name,"r"); $counter=fgets($handle,100000); fclose($handle); return $counter; } ?> <? if($vote=='E1'){//判斷要讀寫哪一個檔案 filecount("counter/counter1.txt"); header("Location:1.php"); exit; }elseif($vote=='E7'){ filecount("counter/counter2.txt"); header("Location:1.php"); exit; }elseif(empty($vote)){ ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <title>測試計數器</title> </head> <body> <table border="1" width="100%" id="table1"> <tr> <td width="54">1</td> <td> <a href="Publish/E1.pdf" onClick="location='1.php?vote=E1'"> <span lang="EN-US" style="font-size: 12.0pt; font-family: Times New Roman"> Tseng, C. H., Tuan*, H. L., &amp; Chin, C. C. (2009).</span><b><span lang="EN-US" style="font-size: 20.0pt; font-family: Plantin-Bold"> </span></b> <span lang="EN-US" style="font-size: 12.0pt; font-family: Plantin-Bold"> Investigating the influence of motivational factors on conceptual change in a digital learning context using the dual-situated learning model. <i> &nbsp;International Journal of Science Education</i>, 1-23</span></a></td> <td width="35"> <?Php echo readcounter("counter/counter1.txt'); ?> </td> </tr> <tr> <td width="54">7</td> <td> <span style="font-size: 12.0pt; font-family: Times New Roman"> <a href="Publish/E7.pdf"onClick="location='1.php?vote=E7'">Tuan, H. L., Chin, C. C., Tsai, C. C.&amp; Cheng, S. F. (2005). Investigating the effectiveness of inquiry instruction on the motivation of different learning styles student. International Journal of Science and Mathematics Education, 3(4), 541-566. (NSC 91-2511-S-018-023).</a></span></td> <td width="35"><? echo readcounter("counter/counter2.txt'); ?> </td> </tr> </body> </html> 請高手幫我看程式碼哪裏寫錯了,網頁出現Parse error: syntax error, unexpected '{', expecting '(' in /home/tuan/www/1.PHP on line 3 說我這行寫錯 function filecount{$file_name){ 還是因為我的伺服器不支援PHP5,或是函數定義錯了 請解救我研究了很久 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 120.107.169.55

07/22 15:55, , 1F
function filecount'{' $file_name )
07/22 15:55, 1F
文章代碼(AID): #1CH_B1tf (PHP)
文章代碼(AID): #1CH_B1tf (PHP)