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

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

Open in new window

Greg AlexanderLead DeveloperCommented:
Hmm, this work?

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

Open in new window

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 ;-)

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

echo $str;

Open in new window

Thanks for the points!
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.