Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 如何以数字格式显示数字_Templates_Drupal_Drupal 7_Number Formatting - Fatal编程技术网

Templates 如何以数字格式显示数字

Templates 如何以数字格式显示数字,templates,drupal,drupal-7,number-formatting,Templates,Drupal,Drupal 7,Number Formatting,这是我在template.php文件中的内容: function twitter_count() { $pageID = 'TWITTERACCOUNT'; $info = json_decode( file_get_contents('https://api.twitter.com/1/users/show.json?screen_name=' . $pageID .'') ); echo $info->followers_count; } 我用这个在一个块中显

这是我在template.php文件中的内容:

function twitter_count() {
    $pageID = 'TWITTERACCOUNT';
    $info = json_decode( file_get_contents('https://api.twitter.com/1/users/show.json?screen_name=' . $pageID .'') );
    echo $info->followers_count;
}
我用这个在一个块中显示结果:

<?php echo number_format(twitter_count("TWITTERACCOUNT") ); ?>
试一试




并从函数中删除该回音。相反,请返回。

运气好吗?我认为现在发生的是函数中的回显正在打印它,即使在块中使用number_格式回显它,它在函数执行时直接回显到stdout,number_格式接收空值,从而格式化null,从而生成空字符串。
36170
<?php echo number_format(intval(twitter_count("TWITTERACCOUNT") ) ); ?>
 <?php echo number_format(floatval(twitter_count("TWITTERACCOUNT") ) ); ?>