Why does my php code return inf?

2019-06-20 07:54发布

I have a math problem where I am trying to calculate the total combination of values in a set... when I try and run my calculation it just returns INF instead of a number...

$tally = 1;
foreach ($output as $key => $er) {
  $tally = $tally *(ord(strtolower($er)) - 96);
}
echo $tally;

1条回答
姐就是有狂的资本
2楼-- · 2019-06-20 08:17

If when you try and echo a number and isntead PHP gives you "INF", it is because PHP thinks that the number is infinite, or too large to be stored in its memory.

You can confirm this by echo is_infinite($tally);

查看更多
登录 后发表回答