Javascript 如何将php中的变量插入到p标记(html)中?

Javascript 如何将php中的变量插入到p标记(html)中?,javascript,php,jquery,html,twitter,Javascript,Php,Jquery,Html,Twitter,我正在努力让我的推特粉丝数量显示在我的网站上。我已经设置了twitterapi来接收跟随者计数,并且已经使用echo进行了测试,效果非常好 问题是我无法解决如何将该值传递到html中 这是获取twitter计数的代码: <?php /* * Requires the "Twitter API" wrapper by James Mallison * to be found at https://github.com/J7mbo/twitter-api-php * * The

我正在努力让我的推特粉丝数量显示在我的网站上。我已经设置了twitterapi来接收跟随者计数,并且已经使用echo进行了测试,效果非常好

问题是我无法解决如何将该值传递到html中

这是获取twitter计数的代码:

<?php 

/* 
 * Requires the "Twitter API" wrapper by James Mallison 
 * to be found at https://github.com/J7mbo/twitter-api-php
 *
 * The way how to get a follower count was posted by Amal Murali
 * on http://stackoverflow.com/questions/17409227/follower-count-number-in-twitter
 */

require_once('twitterapi/TwitterAPIExchange.php');              // adjust server path accordingly

// GET YOUR TOKENS AND KEYS at https://dev.twitter.com/apps/
$settings = array(
'oauth_access_token' => "SECRET",               // enter your data here
'oauth_access_token_secret' => "SECRET",        // enter your data here
'consumer_key' => "SECRET",                 // enter your data here
'consumer_secret' => "SECRET"               // enter your data here
);

$ta_url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?screen_name=SECRET';                  // enter your twitter name without the "@" here
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$follow_count=$twitter->setGetfield($getfield)
->buildOauth($ta_url, $requestMethod)
->performRequest();
$data = json_decode($follow_count, true);
$followers_count = $data[0]['user']['followers_count'];

?>

这是将$u count变量传递到html的代码

它是一个id为“twit follow count”的span标记


$(文档).ready(函数(){
$('twit follow count').html($followers\u count);
});
任何帮助都将不胜感激


<script type="text/javascript">

$( document ).ready(function() {
    $('#twit-follow-count').html('<?php echo $followers_count; ?>');
});

</script>
$(文档).ready(函数(){ $('#twit follow count').html(''; });
是。那就是我要做的!?我投了更高的票。这就是我能做的。我没问这个问题。对不起,没看昵称。对不起,没用。echo弹出的是正确的数字,但不是p标记。您可以使用PHP插入此值,无需真正使用javascript。
<script type="text/javascript">

$( document ).ready(function() {
    $('#twit-follow-count').html('<?php echo $followers_count; ?>');
});

</script>