0

how can I put a javascript in a php variable? :D

now why would I want to do something like that? I want to build a page for my company and I want to insert more like and share buttons from facebook and thought it would be easyer to insert a variable not the whole code where I want to. For that i have to put this code from https://developers.facebook.com/docs/plugins/like-button <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 = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> after the opening body tag and this code: <div class="fb-like" data-href="https://www.facebook.com/paszauto/" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div> where I want the plugin.... The problem is with the " ' If a declare a php variable between "" it ruins the script.... anyone any ideas? Thanks in advance!

15th Jan 2018, 8:19 PM
Szabo Ferencz Levente
Szabo Ferencz Levente - avatar
1 Answer
0
google-d it and it cannot be done because javascript runs client side and php server sided
15th Jan 2018, 8:30 PM
Szabo Ferencz Levente
Szabo Ferencz Levente - avatar