PHP MySQL函数在HTML中的显示

PHP MySQL函数在HTML中的显示,php,mysql,function,Php,Mysql,Function,我有以下功能: function get_current_users($current_users) { global $db; $current_users = $db->EscapeString($current_users); $total_current_users = $db->QueryFetchArray("SELECT COUNT(*) FROM users AS total_current_users"); return $total_current_users[

我有以下功能:

function get_current_users($current_users) 
{
global $db;
$current_users = $db->EscapeString($current_users);
$total_current_users = $db->QueryFetchArray("SELECT COUNT(*) FROM users AS total_current_users");
return $total_current_users['total_current_users'];
}

但我不知道如何输出结果,我尝试了以下选项,但没有显示任何结果:

 `<?$total_current_users?>
 <?['$total_current_users']?>
 <?=data['$total_current_users']?>`
`
`
试试这种语法

$total_current_users = $db->QueryFetchArray("SELECT COUNT(*) as total_current_users FROM users");
您正在从结果集中选择一个要返回的值,该值未命名,请尝试上面的方法使其与代码匹配


然后将模板代码更改为:

如果您确定您的函数执行了它应该执行的操作,我猜两个等效方法将获得输出:


需要注意的是:我不明白您的参数
$current\u users
的意义,因为它在随后的查询中永远不会被使用

当我在my functions.php中使用该语法时,该站点显示为空白,如果有任何方法可以像上面使用函数的示例那样设置格式?在更改任何内容之前,我们应该在函数中查看函数正在做什么,请在
返回
添加
变量转储($total\u current\u users)之前这应该告诉您查询是否在做任何事情。