If you read the documentation carefully, it says-
The XFBML and HTML5 versions of the button allow you to subscribe to the
'edge.create'
event in the Facebook SDK for JavaScript through FB.Event.subscribe. This JavaScript event will fire any time a button is clicked.
And you are using the IFrame version, that's why it isnt working.
Also, it wont work with any version in the localhost
, may be due to some security reasons.
You can use the HTML5 version-
Replace your js.src=...
line with:
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=213893228799718";
and
$a = '<iframe sr....
echo $a;
with
<div class="fb-like" data-href="https://www.facebook.com/MyFanPage" data-layout="button" data-action="like" data-show-faces="true" data-share="true"></div>