php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36889 return in nested & recursive function give NULL
Submitted: 2006-03-28 13:16 UTC Modified: 2006-03-28 13:39 UTC
From: webmaster at solocreation dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.2 OS: Debian Sarge
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: webmaster at solocreation dot com
New email:
PHP Version: OS:

 

 [2006-03-28 13:16 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-28 13:34 UTC] tony2001@php.net
Change 

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

to

if ($AnotherNumber <= 10000) {
return Calc($AnotherNumber);
}
 [2006-03-28 13:39 UTC] webmaster at solocreation dot com
OMG.. shame on me, sorry
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 26 12:00:02 2025 UTC