为什么结果总是整数?

I have the weirdest thing in PHP.

I have a function like this:

function Calculate_i_from_IDF($coef, $Tc)
{
    print_r($coef);
    $intensity=$coef[0]+$coef[1]*$Tc+$coef[2]*$Tc^2+$coef[3]*$Tc^3+$coef[4]*$Tc^4;
    echo "intensity=$intensity<P>";
    return $intensity;
}

My Tc=1. The result is:

Array ( [0] => 1.1413387743 [1] => -0.7177898193 [2] => 0.6190050656 [3] => -0.4272211298 [4] => 0.0813729821 )

intensity=7

What I don't understand is why $intensity is 7 instead of the expected 0.696706. It is so weird! Any help is greatly appreciated.

Thank you,

Frank

^ is not the exponent operator, but a bitwise operator. That is likely causing the expression to result in an integer. Try using pow.

Related: Php, calculating exponent with carrot (^) fails