Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
newbie3

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...