Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Facebook Follow Btn script hindering PHP include.

Featured Replies

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?).

  1. 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.
  2. 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.