note 118706 rejected from language.variables.scope by mazzanet

From: Date: Tue, 26 Jan 2016 11:51:28 +0000
Subject: note 118706 rejected from language.variables.scope by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-204764@lists.php.net to get a copy of this message
Note Submitter: 16621596 at qq dot com ---- function myfunc($num) { static $result = 0; $num--; $result++; echo "num: $num result: $result" . "<br />"; if($result == 10) { return $result; } myfunc($num); } $a = myfunc(5); var_dump($a); /************************/ run code above, the result is: num: 4 result: 1 num: 3 result: 2 num: 2 result: 3 num: 1 result: 4 num: 0 result: 5 num: -1 result: 6 num: -2 result: 7 num: -3 result: 8 num: -4 result: 9 num: -5 result: 10 null Why the result value of this function is null?

« previous php.notes (#204764) next »