Templates 如何以数字格式显示数字
这是我在template.php文件中的内容: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; } 我用这个在一个块中显
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") ) ); ?>