karto
karto

Reputation: 3658

PHP/HTML echo a variable in a div

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?

Upvotes: 0

Views: 4572

Answers (4)

Lawrence Cherone
Lawrence Cherone

Reputation: 46602

Try This:

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

Upvotes: 0

Eskil Mjelva Saatvedt
Eskil Mjelva Saatvedt

Reputation: 547

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

Upvotes: 0

genesis
genesis

Reputation: 50966

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

Upvotes: 0

Yoshi
Yoshi

Reputation: 54649

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

Upvotes: 3

Related Questions