You are here: Recursionalism « PHP Programming Language « IT news, forums, messages
Recursionalism

Posted by blessblessbless on 05/04/07 00:52

Hey all,
I am self taught in PHP and my method is just trial and error most of
the time, but when trying doe not help anymore I get frustrated... I'm
sure some of you know what I mean.

My problem is with a recursive(referring back to itself) function I am
trying to write.
The function works well on its own, and it also works recursively as
many times as I want it to.
I am going to give you a lite version of the function because it
doesn't really matter what it does.

global $counter;
$counter=0;
function recursion($value){
$counter++;
if ($counter > 10){exit("Recursion exceeded limit!");}

$newvalue= blabla something with $value

if (condition applies){recursion($newvalue);}
return $newvalue;
$counter=0;
}

SO my problem is, the counter is not working. I know it has something
to do with the fact that functions use their own variables, buts that
is why I thought to set the counter as global :/
Anybody have an idea why it wont stop and my apache crashes when I try
to repeat the function limitless? (ok i know why it crashes, just not
why the function does not stop;

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация