Many ASPs who have first learned from ASP may be lost in dual quotes, single quotes, and & numbers. The most important thing is that the meaning of three types of symbols is not understood, and of course, they can't master their usage well. Here are my views on the three types of symbols. The technology is not fine, and there are inevitable negligence. Please ask everyone to give more opinions.
1. Double quotation "" "" ""
In ASP, there can be any characters, string, and HTML code in the dual quotes.
for example
The following is the code fragment: <%Response.write ("CNBRUCE Here")%> <hR> <%Response.write ("<b> CNBRUCE Here </a>")%> |
The effects of the pages generated are: default text and bold text "CNBRUCE Here"
Let's think about it, what should I do if I want to add a color effect to the output page text?
1. General text color: <font color = "#0000ff"> cnbruce </font>
2. Response.write writing is this: response.write ("Input displayed content")
3. If you want to put the above hyperlink code in the response.write, have you found that the dual quotes in the WRITE method and the dual quotes in the color in the WRITE method form the nested effect.
Response.write is bound to form (<font color = "#0000ff"> cnbruce </font> ")
4. The debugging result is not optimistic, because the quotation marks of Color and the front quotation of WRITE form matching, and the content is <font color =; the same colorary of color is matched with the quotation of the WRITE. The content is:> cnbrule </font </font " The end result is:#0000ff in the middle is lonely.
5, so for the correct result, you can put#0000FF as a string in a dual quotation number, and then the string with the front string <font color = and the rear string> cnbruce </font> is used.
The final result is as follows:
The following is the code fragment: <% Response.write ("<font color =" & "#0000ff" & "> cnbruce </font>") %> |
2. Single quotation number ''
Just like learning Chinese lessons, the quotes that continue to be placed in the dual quotation can be used.
Then the#0000FF in the above statement response.write ("<font color ="#0000ff "> cnbrule </font>") can turn its dual quotes into single quotes:
Response.write (<font color = '#0000ff'> cnbruce </font> "), so the execution is also correct.
3. Connection character & number
The main function of ASP is used to connect, including: string-string, string-string-variables, variable-variables, etc.
For example, a question below:
The following is the code fragment: <% MyColor = "#0000ff" Response.write (<font color = '"& mycolor &"'> "&" cnbrule "&" </font> ") %> |
What needs to be noticed is: COLOR's single quotation number uses dual quotes ~! You may be confused, watch slowly.
1. Now I define a variable MyColor. According to principles, the variables do not need to add double quotes in response.write, because adding dual quotes is a string, not variables.
2, so if response.write wants to output variables, you can write it directly: response.write (mycolor)
3. But now. Our variables must be placed in the dual quotes (for example, the above program is placed in a single quotation), so how should the specific response.write be written?
4. Key writing: Continue the variables in ASP to continue to add left and right "& include, and you can put it in the quotation marks of response.write.
5. Analysis of response.write ("" "" "" & MyColor & ""), in fact, it is the previous empty string connecting MyColor variable and then connected to a string.
6, so now we should understand the entire example of the upper ASP.
Continue to strengthen and deepen