本文介绍了为什么我的PHP代码返回inf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数学问题,我试图计算一组值的总和...当我尝试运行我的计算时,它只返回INF而不是数字...
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;
推荐答案
如果您尝试回显一个数字并且不满意PHP给您 INF,这是因为PHP认为该数字是无限的,或者太大而无法存储在其内存中。
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.
您可以通过<$ c来确认$ c> echo is_infinite($ tally);
这篇关于为什么我的PHP代码返回inf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!