newbie3 Posted January 29, 2012 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 Link to comment Share on other sites More sharing options...
Jonathon Posted January 30, 2012 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 Link to comment Share on other sites More sharing options...
newbie3 Posted January 30, 2012 Author 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 Link to comment Share on other sites More sharing options...
Recommended Posts