note 82741 deleted from functions.returning-values by mgf
| From: | mgf@php.net | Date: | Mon, 09 Jun 2008 10:59:38 +0000 |
| Subject: | note 82741 deleted from functions.returning-values by mgf | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-140263@lists.php.net to get a copy of this message | ||
Note Submitter: sandeepkhokher at gmail dot com
----
About returning the value from a recursive function
If you are calling a recursive function then it would not return the value to the calling function
unless you would declare the returning variable as global.
for example
<?php
function GetDestinationChild($id)
{
global $ar;
//do some operation
//if some results comes
if($cnt>0)
{
//call itself $this->GetDestinationChild($obj_2->dest_id);
}
else
{
//return computed value
return $ar;
}
}
?>
if you would not define the returning variable as global it would not return the desired computed
value