ASP中单引号双引号和连接符使用技巧

ASP中单引号双引号和连接符使用技巧

一、单引号:如学习语文课一样,继续放在双引号中的引号可以采用单引号 
response.write("I am here") 

二、ASP中处在双引号中的可以是任意的字符、字符串,HTML代码 
1.<%response.write ("I am here")%><%response.write ("cnbruce here")%> 
2.<%response.write ("<b>I am here</b>")%> 
3.<双引号为就近匹配,如有单引号AND连接符包含于和连接将<延后引号>>response.write("I am here") 
因为color的前引号和write的前引号形成匹配,内容为I am here。最终结果是:中间的 #0000ff 被孤单了 
<%response.write("<font color=" & "#0000ff" & ">I am here</font>")%> 
<% 
response.write("cnbruce") 
%> 

三、ASP中&号的主要作用是用来连接的,包括:字符串-字符串、字符串-变量、变量-变量等混合连接 
<% 
mycolor="#0000ff" 
response.write ("<font color= "&mycolor&" >" & "cnbruce" & "</font>") 
%> 
<% 
mycolor="#0000ff" 
response.write ("" & "cnbruce" & "") 
%> 
单引号(双引号中不用)中<变量保持>关键写法:<将ASP中的变量继续添加左右的"&包括>,就可以放到response.write的引号中了,效果即为:response.write(" "&mycolor&" ") 
注:asp<输出response主要处理变量,字符串,html代码>(对单一标记可做为字符串来处理) 
response.write"a" 
response.write("a") 
显示一样都是输出的<字符串a,> 
而response.write(a)和<%=a%><%=a%>输出的是变量a 的值。

dawei

【声明】:站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。