Link to home
Start Free TrialLog in
Avatar of NewWebDesigner
NewWebDesigner

asked on

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

Avatar of Greg Alexander
Greg Alexander
Flag of United States of America image

Hmm, this work?

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Thanks for the points!