February 15, 201610 yr I'm trying to load all my follow buttons under a global php variable $follow. It was working until lines 13 - 20 was entered. It seems php has a problem integrating a script into it's vibe (not sure if it's a statement here?). I put the twitter script outside and in the html file below the $follow php variable and it works, but this does not work with facebook. I noticed I was getting errors around line 20 \'script\', \'facebook-jssdk\'));</script>'; and this was from the single quotaion marks; which I solved by using the escape character \ prior each occurence. <?php $follow = '<div class="g-fol"> <div class="g-follow" data-annotation="none" data-height="20" data-href="//plus.google.com/u/0/113326011335089676289" data-rel="author"></div> </div> </div> <div class="twit-fol"> <a href="https://twitter.com/PreciseFormwork" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @PreciseFormwork</a> </div> <div class="pin-fol"> <a data-pin-do="buttonPin" data-pin-count="none" href="https://www.pinterest.com/pin/create/button/?url=https%3A%2F%2Fuk.pinterest.com%2Fpreciseform0204%2F&media=https%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg&description=Next%20stop%3A%20Pinterest"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a> </div> <div class="fb-follow" data-href="https://www.facebook.com/Precise-Formwork-Ltd-192240647483941/" data-layout="button" data-show-faces="false"></div>'; echo '<div id="fb-root"></div>'; '<script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.5"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\'));</script>'; echo $follow; echo '<p class="buttons"><button onclick="Generate">unclicked</button></p>'; ?> Anyone know any good ways around this? I suppose I could use a JS global variable but wouldn't I have to do this on each document. I have a tiny bit more experience in PHP than JS (still nothing really) but a lot of work's gone in on this already. Regards
Create an account or sign in to comment