重庆大学创新实践班:请教这段asp的代码什么作用?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/11 20:48:14
<% keyword=split(keyword,"|")
function key()
for i=0 to ubound(keyword)
response.write keyword(i)&","
next
end function
%>

后面接下去是这样的:
<html>
<head>
<title><%=webname%></title>
<meta name="description" content="本程序由枝叶设计编写!">
<meta name="keywords" content="<%=key()%>">
<link rel="stylesheet" type="text/css" href="images/style.css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="枝叶主页" content="http://www.zyhot.com">
</head>
<body bgcolor=#FFFFFF leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
<div align="center">

其他的没什么说的,主要部分就是
<% keyword=split(keyword,"|")
function key()
for i=0 to ubound(keyword)
response.write keyword(i)&","
next
end function
%>
一个方法,循环写入字符串的。

以循环方式输出所有“keyword”数组的元素!
split(keyword,"|")把字符串定义为数组,以“|”分隔
ubound(keyword) ubound最大下标函数

其他的没什么说的,主要部分就是
<% keyword=split(keyword,"|")
function key()
for i=0 to ubound(keyword)
response.write keyword(i)&","
next
end function
%>
一个方法,循环写入字符串的。

上面那段是将"keyword"按"|"分为一个数组:
如"1|2|3"使用split(keyword,"|")后得到一个数组:
keyword(0)=1
keyword(1)=2
keyword(2)=3

然后将这些值用","连接起来。
其实他转了一个大弯,代码可以简单的写为:
<%
keyword=replace(keyword,"|",",")
%>

<meta name="keywords" content="<%=key()%>"> 改为<meta name="keywords" content="<%=keyword%>">