开发者

Fatal error: Allowed memory size of 134217728 bytes exhausted

I have a problem in my php code that uses recursion:

<?php

solveTowers(5, "A", "B", "C");

 function solveTowers($count, $src, $dest, $spare)
    {
        if (count == 1)
        {
          echo "Move a disk from ".$src." to ".$dest ;
        }
        else
        {
            solveTowers($count - 1, $src, $spare, $dest);
            solveTowers(1, $src, $dest, $spare);
            solveTowers($count - 1, $spare, $dest, $src);
        }
    }

?>开发者_JS百科

But it doesn't run!

This error occurs:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in C:\xampp\htdocs\cap492\towers.php on line 13

Line 13 is the first call to the function in the else statment

Can you please help me with this?!


if ($count == 1) instead of if (count == 1)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜