newbie3 4 Posted January 29, 2012 Report Share Posted January 29, 2012 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 Quote Link to post Share on other sites
Jonathon 255 Posted January 30, 2012 Report Share Posted January 30, 2012 Single quotes will print literally $name. You need to concatenate with single quotes in order to actually print the $variables value. 1 Quote Link to post Share on other sites
newbie3 4 Posted January 30, 2012 Author Report Share Posted January 30, 2012 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 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.