We all have Facebook pages for brands, Public Profile etc, and most of us add our Facebook page widget in website’s sidebar which is traditional like box and simple count of likes. In this tutorial I will give you a very small code of PHP using that code you can get any Facebook page likes in text format with name and you can show your fan count in a nice layout to your users according to your theme.
This is a very simple and easy to configure script I am using FQL query with Facebook API.
$data = file_get_contents('http://api.facebook.com/method/fql.query?format=json&query=select+fan_count,name+from+page+where+page_id%3D254602424641921');
$decode = json_decode($json);
Above code send request to Facebook API for fan_count and name page counts and name of the page in FQL with format json means returning data will be in json format after that we decode json and echo fan_count and name of page.
This is a very simple and short and very useful code. I hope it helps you please give us your feedback.