Php summary 6.0 -- custom function, reference value passing, php6.0
6.1 User-Defined Functions
Function Name (parameter [= default value], parameter [= default value]...) {
Function body
[Return val];
}
1) No parameter is returned
2) if a parameter exists, no response is returned.
3) if any parameter is returned
The code in the function is not executed immediately and will be executed only when called.
Call: function name ([parameter list])
Question: What are the differences between the following two functions?
Function demo {
Echo 1111;
} // 1111 is printed on the page and cannot be assigned to a variable.
Function demo {
Return 1111;
} // It is not printed on the page, but can be assigned to a variable.
4) recursive functions
Recursive functions must be terminated.
It is often used in php to recursively Delete directory files.
6.2 reference and pass value of a Variable
Reference Value: php allows multiple variables to point to the same memory space.
The reference transmits the content.
Question: What are the output of the following two programs?
<? Php $ a = 3; $ B = $ a; $ a = 4; echo $ B; // 3?> <? Php $ a = 3; $ B = & $ a; $ a = 4; echo $ B; // 4?>