0

I have a div which works fine

  <div id="fb-root"></div>
   <fb:like href="<?php echo $link; ?>" send="true" width="450" show_faces="true" font=""> 
   </fb:like>

If I try to use an echo, I don't get the value of $link when I do this.

echo '<div id="fb-root"></div>
<fb:like href="<?php echo $link; ?>" send="true" width="450" show_faces="true" font="">
</fb:like>';

likewise this one too. i cannot get the $link.

echo '<iframe src="http://www.facebook.com/plugins/like.php?app_id=208015255907895&amp;href="',$link,'"&amp;send=true&amp;layout=button_count&amp;width=50&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=trebuchet+ms&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe> '

Any help?

1
  • pls see the $link with the answer from @fender echo '<iframe src="facebook.com/plugins/…" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe> ' Commented Jul 27, 2011 at 12:50

4 Answers 4

3

You can't use <?php ... ?> in an echo. Try:

echo '<div id="fb-root"></div><fb:like href="', $link, '" send="true" width="450" show_faces="true" font=""></fb:like>';
Sign up to request clarification or add additional context in comments.

8 Comments

shouldn't it be echo '<div id="fb-root"></div><fb:like href="'. $link. '" send="true" width="450" show_faces="true" font=""></fb:like>'; . instead of ,
@Fender: , works too (remember, that echo is a language construct and not a function). The difference: echo $a,$b; is like echo $a; echo $b; and . is the common concatenation. ideone.com/hDbwq or ideone.com/89iww : Note, that in the first example the string `"Hello object:" is returned, but in the second one is not.
@Fender It doesn't matter in case of echo
@Fender Try echo 'foo', 1 + 2, 'bar'; echo 'foo' . 1 + 2 . 'bar'; and you'll see why I tend to use , with echo. :)
oh yea... you are right. Never thought of it this way ;-) You never stop learning :-)
|
0
echo '<div id="fb-root"></div><fb:like href="'.$link.'" send="true" width="450" show_faces="true" font=""></fb:like>';

you cannot add <?php ?> brackets into your echo

Comments

0

you are messing up ' " and a new php tag

echo '<div id="fb-root"></div>
<fb:like href="'. $link .'" send="true" width="450" show_faces="true" font="">
</fb:like>';

Comments

0

Try This:

echo '<div id="fb-root"></div>
 <fb:like href="'.$link.'" send="true" width="450" show_faces="true" font="">
 </fb:like>';

1 Comment

see this too. $link seems not to work '<iframe src="facebook.com/plugins/…" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height:21px;" allowTransparency="true"></iframe> '

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.