Hi,
your call to abc_recurse returns the return value of the FIRST call. You
forgot to pass the result back to the calling funtions (below corrected
code).
<?php
function abc_recurse($imax) {
static $i=1;
if ($i == $imax) {
return "xyz";
} else {
$i++;
return abc_recurse($imax);
}
}
echo "\n\nFinal Return:" . abc_recurse(4);
?>
Regards
--
Rainer Rosenberger
__________________________________________________________
NetAktiv, Beratung & Realisierung
Dr. Rainer Rosenberger, Fürholzer Weg 6b, D-85375 Neufahrn
Fon:+49 8165 66506, Fax:+49 8165 66507, Mobil:+49 172 7789381
mailto:[EMAIL PROTECTED] http://www.NetAktiv.de/
__________________________________________________________
"Jaskirat" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
> How to get return value from a recursive function .. here is the test code
> which I was trying
>
> <?
> function abc_recurse()
> {
> static $i = 1;
> echo $i;
> $i++;
> if ($i == 4) return ("xyz");
> abc_recurse();
>
> }
>
> $returnvalue = abc_recurse();
> echo $returnvalue;
>
> ?>
> Its printing "123" where as I was expecting "123xyz"
> what is happening to $returnvalue
>
> TIA
> Jaski
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]