The return Bug in PHP _ recursive functions. I recently used PHP to write small examples of design patterns. a large number of design patterns call objects or functions recursively. Sometimes return is required to return the processing status. In JAVA, I recently used PHP to write small examples of design patterns. a large number of design patterns call objects or functions recursively. Sometimes return is required to return the processing status. In JAVA, you only need to return the result within the function. In PHP, you must add return to the recursive function before it can be used normally.
For example
01
02
/**
03
* When calling this method, you need to call the function recursively when $ I <3. If it is in JAVA, the $ I value can be returned, but PHP cannot.
04
*/
05
Function TestReturn ($ I ){
06
If ($ I <3)
07
{
08
$ I ++;
09
TestReturn ($ I );
10
}
11
Return $ I;
12
}
13
14
/**
15
* In PHP, you must add return when calling a function recursively.
16
*/
17
Function TestReturn ($ I ){
18
If ($ I <3)
19
{
20
$ I ++;
21
Return TestReturn ($ I );
22
}
23
Return $ I;
24
}
25
26
?>
Author: si Yun Qilin
Bytes. Sometimes return is required to return the processing status. In JAVA...