#36889 [Bgs]: return in nested & recursive function give NULL

From: Date: Tue, 28 Mar 2006 11:39:56 +0000
Subject: #36889 [Bgs]: return in nested & recursive function give NULL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94985@lists.php.net to get a copy of this message
 ID:               36889
 User updated by:  webmaster at solocreation dot com
 Reported By:      webmaster at solocreation dot com
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Debian Sarge
 PHP Version:      4.4.2
 New Comment:

OMG.. shame on me, sorry


Previous Comments:
------------------------------------------------------------------------

[2006-03-28 13:34:12] tony2001@php.net

Change 

if ($AnotherNumber <= 10000) {
Calc($AnotherNumber);
}

to

if ($AnotherNumber <= 10000) {
return Calc($AnotherNumber);
}

------------------------------------------------------------------------

[2006-03-28 13:16:09] webmaster at solocreation dot com

Description:
------------
with sample code, output is :
$AnotherNumber=200000
NULL

so variable is set and correct, but return always assign NULL to $Test

if it's not a  bug, I'd like to know what I'm doing wrong ??

Reproduce code:
---------------
<?php
Function Multipl($Number) {
return $Number*100;
}


Function Calc ($AnotherNumber) {

$AnotherNumber = Multipl($AnotherNumber);

if ($AnotherNumber <= 10000) {
Calc($AnotherNumber);
}
else {
echo '$AnotherNumber='.$AnotherNumber.'<br />';
return $AnotherNumber;
}
}

$Test = Calc(20);
var_dump($Test);
?>

Expected result:
----------------
$AnotherNumber=200000
200000

Actual result:
--------------
$AnotherNumber=200000
NULL


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36889&edit=1


Thread (3 messages)

« previous php.bugs (#94985) next »