Jump to content
Larry Ullman's Book Forums

Ch5 Use Concatenation With Function Pg 105


Recommended Posts

Hi there

 

According to the book, the two print statements below are the same.

 

1. (On page 104) print "<p>Click <a href=\"thanks.php?name=$name&email=$email\">here</a>to continue.</p>" ;

 

2. (On page 105) print 'Click <a href="thanks.php?name=' . $name . '&email=' . $email . ' ">here</a>to continue.' ;

 

What we don't understand is that why use concatenation, why not the print statement (on page 105) looks like below (without concatenation)

 

print 'Click <a href="thanks.php?name=$name&email=$email">here</a>to continue.' ;

Note: the print above contains double quotes for the url and because the single quotes of the print are used, no escape of double quote is required.

 

We believe we miss something but not sure what it is.

 

Thanks in advance for any explanation.

 

Regards

Link to comment
Share on other sites

Hi there

 

Thank you very much, we see it now, as the components are :

  • 'Click <a href="thanks.php?name='
  • $name
  • '&email='
  • $email
  • ' ">here</a>to continue.'

 

With that, $variable, instead of literal (eg $name) is printed.

 

Regards

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...