How to add the facebook like button to our Webpage

Now it is easy to make our page SEO friendly, by adding facebook like button or Bookmarking button to our webpage this makes the user easy to bookmark our sites for their future use. This will make our site userfriendly and SEO friendly.

Now let us see how to add Facebook like button

1. To get the current page url call the function


<?php
 $currentpageURL=curPageURL();
 ?>

2.  Function for getting current page url

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

3.Assign the value to the following code

<pre><span style="color: #000000;"><div align="left">
 <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $currentpageURL;?>&amp;layout=standard&amp;show_faces=true&amp;width=550&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:550px; height:80px;" allowTransparency="true"></iframe>
 </div></span>
Posted in General, Html, Php Tagged with: ,