concatenating strings in PHP

I need help concatenating this string.  Currently I am getting an error message.
echo "<div class=\"searchResults\" onclick=\"popUp('$gmail','" . echo $r++ . ")\">";

Open in new window

NewWebDesignerAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
What about :
echo "<div class=\"searchResults\" onclick=\"popUp('$gmail','" . ($r++) . "')\">";

Open in new window

0
 
Greg AlexanderLead DeveloperCommented:
Hmm, this work?

echo "<div class=\"searchResults\" onclick=\"popUp('$gmail','" . echo $r++; . ")\">";
0
 
Greg AlexanderLead DeveloperCommented:
Or this:
echo "<div class=\"searchResults\" onclick=\"popUp('".$gmail."','" . echo $r++; . ")\">";

Open in new window

0
 
Ray PaseurCommented:
All those quotes and nested instructions are hard to understand.  Suggest you use one instruction per line and try to learn about HEREDOC notation - much easier to get right the first time ;-)
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Maybe you want something like this?
$str = <<<ENDSTRING
<div class="searchResults" onclick="popUp('$gmail','$r++')">
ENDSTRING;

echo $str;

Open in new window

0
 
leakim971PluritechnicianCommented:
Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.