Jump to content
Larry Ullman's Book Forums

Script 2.6 Line 24 Syntax For Value Attribute


Recommended Posts

In Script 2.6 (page 61) you introduce the syntax for using the "foreach" loop to use array to generate selection options for the pull-down (in this case, the months of the year).

 

In line 24 the opening Option Tag has the value attribute typed as follows: value=\"$key\"

 

Can you please explain the use of the back slashes that appear both before the variable name and also within the quotes following the variable name?

 

I don't believe it is explained previously in the text, but it is used repeatedly throughout the rest of the chapter.

 

Thank you.

 

Link to comment
Share on other sites

Sorry for the confusion! The double quotes there are for the HTML (to wrap the value) and if they aren't escaped, they'd create a conflict with the double quotes used for the entire print statement. In other words, those quotes are escaped to literally print a double quote character.

Link to comment
Share on other sites

  • 2 weeks later...
 Share

×
×
  • Create New...