你好,欢迎访问远方教程PC版!
广告位招租
网站首页 >> ASP教程 >> ASP基础入门 >> 文章内容

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

[日期:2015-01-23]   来源:远方教程  作者:远方教程   阅读:2680次[字体: ] 访问[旧版]
 捐赠远方教程 

  一、ASP中处在双引号中的可以是任意的字符、字符串,HTML代码
  1.<%response.write ("I am 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("I am here")

  三、ASP中&号的主要作用是用来连接的,包括:字符串-字符串、字符串-变量、变量-变量等混合连接

  <%
  mycolor="#0000ff"
  response.write ("<font color= "&mycolor&" >" & "cnbruce" & "</font>")
  %>

  单引号(双引号中不用)中<变量保持>关键写法:<将ASP中的变量继续添加左右的"&包括>,就可以放到response.write的引号中了,效果即为:response.write(" "&mycolor&" ")

  注:asp<输出response主要处理变量,字符串,html代码>(对单一标记可做为字符串来处理)

  response.write"a"

  response.write("a")

  显示一样都是输出的<字符串a,>

  而response.write(a)和<%=a%>输出的是变量a 的值.

图片展示
 
相关评论
站长推荐