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

时间:2023-03-09 01:02:07
ASP中双引号单引号和&连接符使用技巧
ASP中双引号单引号和&连接符使用技巧

一、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")   %>   二、单引号:如学习语文课一样,继续放在双引号中的引号可以采用单引号   response.write("I am here")   三、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 的值