建議:解讀用asp編寫類似搜尋引擎功能的程式碼首先建立一個access 資料庫,庫中有一個URLINDEX表,其中URL和Keywords欄位分別加入了索引,如下: URL 文字(索引:有(無重複)) Title文字Description文字Summary文字Keywords文字(索引:有(無重複)) 程式檔案doquery.asp,程式碼: HTMLHEADTITLE簡單搜尋引擎
我們經常看到直接用left截字符串時,因為標題中會出現漢字和英文共存,所以造成兩條新聞標題長度不一,為了解決這個問題我們可以使用下面這個函數。 <% '************************************************* * '函數名稱:gotTopic '作用:截字串,漢字一個算兩個字符,英文算一個字符 '參數:str----原字串 'strlen----截取長度 '傳回值:截取後的字串 'Copyright:asp教程 '************************************************* * FunctiongotTopic(ByValstr,ByValstrlen) Ifstr=Then gotTopic= ExitFunction EndIf Diml,t,c,i,strTemp str=Replace(Replace(Replace(Replace(str,,),,Chr(34)),>,>),<,<) l=Len(str) t=0 strTemp=str strlen=CLng(strlen) Fori=1Tol c=Abs(Asc(Mid(str,i,1))) Ifc>255Then t=t+2 Else t=t+1 EndIf Ift>=strlenThen strTemp=Left(str,i) ExitFor EndIf Next IfstrTemp<>strThen strTemp=strTemp&… EndIf gotTopic=Replace(Replace(Replace(Replace(strTemp,,),Chr(34),),>,>),<,<) EndFunction %> <% str=共11111w有漢字 str1=一共有五漢字 response.writegotTopic response.writegotTopic(str,10)& &gotTopic(str1,10)& response.writeleft response.writeLeft(str,5)& &Left(str1,5) response.end %> |
分享:揭秘解決防毒軟體誤刪asp檔的方法有些防毒軟體常會把某些asp檔當成病毒刪除,有時簡直防不勝防,程式莫名其妙的就不能用了,因為少了檔~~。這主要是因為,防毒軟體將某些asp程式碼當成木馬關鍵字,記錄保存著,所以遇到有這個關鍵字,就會禁止運行或刪除。 解決的方法是將這些關鍵字給