ASP 定義常量的方法
常量:用一種名稱代替數字和字符串,且其值保持一直不變。
在 VBscript 中,可以用 const 語句來定義常量。
常量分數字型和字符串型。
表示日期的常量寫在兩個 # 之間。
示例:
以下爲引用內容: <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> ASP 定義常量 </title> </head> <body> <% const a=123456789 //定義的常量爲數字 const b="<hr width=120 align='left'/>定義常量<hr width=120 align='left'/>>" //定義的常量爲字符串 const c=# 2010-01-16 # //日期要寫在兩個# 之間 response.Write a response.Write b response.Write c %> </body> </html> |
運行結果:
123456789
定義常量
2010-01-16