Fatal error with php code
Posted
by basma
on Stack Overflow
See other posts from Stack Overflow
or by basma
Published on 2010-05-25T12:08:54Z
Indexed on
2010/05/25
12:11 UTC
Read the original article
Hit count: 293
hello
i have a problem in my php code that use 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);
}
}
?>
but it doesnt run !!
this error accures : 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 that ?!
© Stack Overflow or respective owner