如何将php代码放入javascript中?

如何将php代码放入javascript中?,javascript,php,wordpress,Javascript,Php,Wordpress,请在下面的脚本中找到 我想在url变量上插入一个链接 <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function ($) { $(".to-lock-1").sociallocker({ text: { header: "<center>The content is locke

请在下面的脚本中找到

我想在url变量上插入一个链接

<script type="text/javascript">
jQuery.noConflict();                    
jQuery(document).ready(function ($) {
    $(".to-lock-1").sociallocker({
        text: {
            header: "<center>The content is locked!</center>",
            message: "<center></br>Please support us, click like button below to download the Wallpaper.</center>"
        },

        theme: "starter",

        locker: {
            close: false,
            timer: 0
        },

        buttons: {                                
            order: ["facebook-like", "twitter-tweet", "twitter-follow", "google-plus", "linkedin-share"]
        },

        facebook: {  
            appId: "206841902768508",
            like: {
                title: "Like us",
                url: "https://www.facebook.com/9H9Gang"
            }
        },

        twitter: {
            tweet: {
                title: "Tweet",
                text: "PHPGang Programming Blog, Tutorials, jQuery, Ajax, PHP, MySQL and Demos.",
                URL: "http://www.phpgang.com/"
            },
            follow: {
                title: "Follow us",
                url: "http://twitter.com/phpgang"
            }
        },

        google: {                                
            plus: {
                title: "Plus +1",
                url: "http://www.phpgang.com/"
            }
        },

        linkedin: {
            url: "http://www.phpgang.com/",                                
            share: {
                title: "Share"
            }
        }
    });
});

//注意?php标记周围的引号
var htmlString=“”//把你的代码放在这里
警报(htmlString);

试试这个。这是一个简单的例子…谢谢你

我对php和JavaScript的知识可能有重复,但是非常有限,你能帮我在上面的脚本中插入代码吗
        twitter: {
        tweet: {
            title: "Tweet",
            text: "PHPGang Programming Blog, Tutorials, jQuery, Ajax, PHP, MySQL and Demos.",
            URL: "http://www.phpgang.com/"
        },
        follow: {
            title: "Follow us",
            url: "http://twitter.com/phpgang"
        }
    }
<?php $htmlString= 'testing'; ?>
<html>
  <body>
    <script type="text/javascript">  
      // notice the quotes around the ?php tag         
      var htmlString="<?php echo $htmlString; ?>"; //put your code here
      alert(htmlString);
    </script>
  </body>
</html>