We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

concatenating strings in PHP

NewWebDesigner
on
Medium Priority
237 Views
Last Modified: 2012-05-11
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

Comment
Watch Question

Greg AlexanderLead Developer

Commented:
Hmm, this work?

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

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

Open in new window

Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Most Valuable Expert 2011
Author of the Year 2014

Commented:
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

leakim971Multitechnician
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Thanks for the points!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.