致命错误:内存不足(已分配1947467776)(试图分配65488字节)


Fatal error: Out of memory (allocated 1947467776) (tried to allocate 65488 bytes)

我正在运行一个非常简单的函数,但得到内存超时问题,有什么建议吗?

function getSum($value)
{
    return  getsum($value) + "58";
}
echo getSum(5) // I would expect it to show 63

但是我得到:

Fatal error: Out of memory (allocated 1947467776) (tried to allocate 65488 bytes) in C:'Users'

这是进入一个无限循环,因为getSum()总是被递归调用。

你应该这样做:

 function getSum($value)
{
    return  $value + 58;
}
相关文章: