表达式总是等于0

时间:2015-01-22 19:42:05

标签: php wordpress function expression shortcode

函数profile_lvl()的输出是3,而函数profile_percentage()的输出是0.我尝试使用整数转换,但是没有用。我完全不知道这件事。

function profile_lvl() {
$profilelvl = do_shortcode( '[mycred_my_rank user_id = "'.bp_displayed_user_id().'"]' );
return $profilelvl;
}
function profile_percentage() {
$profilelvl = profile_lvl();
$profilepercentage = $profilelvl*99;
return $profilepercentage;
}

1 个答案:

答案 0 :(得分:1)

我认为你的变量中有html标签,所以你可以用:

提取数字
$profilelvl = filter_var(profile_lvl(), FILTER_SANITIZE_NUMBER_INT);