• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

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

0
NewWebDesigner
Asked:
NewWebDesigner
  • 2
  • 2
1 Solution
 
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
 
leakim971PluritechnicianCommented:
What about :
echo "<div class=\"searchResults\" onclick=\"popUp('$gmail','" . ($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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now