note 82741 added to functions.returning-values
| From: | sandeepkhokher at gmail dot com | Date: | Wed, 23 Apr 2008 23:21:35 +0000 |
| Subject: | note 82741 added to functions.returning-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138721@lists.php.net to get a copy of this message | ||
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
----
Server IP: 202.89.58.1
Probable Submitter: 202.175.137.165
----
Manual Page -- http://www.php.net/manual/en/functions.returning-values.php
Edit -- https://master.php.net/note/edit/82741
Del: integrated -- https://master.php.net/note/delete/82741/integrated
Del: useless -- https://master.php.net/note/delete/82741/useless
Del: bad code -- https://master.php.net/note/delete/82741/bad+code
Del: spam -- https://master.php.net/note/delete/82741/spam
Del: non-english -- https://master.php.net/note/delete/82741/non-english
Del: in docs -- https://master.php.net/note/delete/82741/in+docs
Del: other reasons-- https://master.php.net/note/delete/82741
Reject -- https://master.php.net/note/reject/82741
Search -- https://master.php.net/manage/user-notes.php