Why does the function return at the end?
天蓬老师2017-07-09 20:52:50
Function, as an important code reuse tool, has many characteristics that need to be understood:
1. The function must have a caller. For some functions, you may feel which one is calling, but in fact it is the system calling .
2. The function must complete a specific function, or perform a predefined action, or return a processing result. No matter what, a feedback must be given to the caller to let the caller know what the result of the function is so that further action can be taken.
3. Functions Many times, you can see a value or an object to use.
4. Remember, functions cannot be placed on the left side of assignment statements, and assignment to a function is not allowed.
5. The function can have no name. In this case, it is an anonymous function. This is very useful, especially during callbacks.
6. Functions can be automatically executed when they are defined, calling self-calling functions: (function(){//code})(). Since such functions are often disposable, anonymous functions are mostly used.
7. There are many ways to call functions, that is, they can be called by the programmer according to the traditional method, or they can be called using some system functions, such as: call_user_func_array(), etc.
8. Functions are powerful. If you make good use of them, your work efficiency can be greatly improved, the code will be more standardized and easy to maintain~~
For more function knowledge, you can refer to the PHP Chinese website (www.php.cn) Related courses~~
——Peter Zhu