The difference between PHP return and exit: 1. Return is at the language level, which represents the return of the call stack, while exit is at the system call level, which represents the end of a process. 2. Return is the exit of the function, and exit is the exit of the process.
Recommended: "PHP Video Tutorial"
The difference between PHP return and exit:
die(): stops when an error is encountered, stops the program running, and outputs the content (yes Program level)
exit(): is a function
is to stop the program running, the former does not output content; the latter outputs content (program level)
exit(0): Run the program normally and exit the program;
exit(1): Exit the program due to abnormal operation;
return: just a keyword
return is a pure return value, but it will not run subsequent code (at the function level)
Additional:
1. Return is at the language level, which represents the return of the call stack; exit is at the system call level, which represents the end of a process.
2. Return is the exit (return) of the function; exit is the exit of the process.
3. Return is provided by C language, and exit is provided by the operating system (or given in the function library).
4. Return is used to end the execution of a function and transfer the execution information of the function to other calling functions;
The exit function is to exit the application and delete the memory space used by the process. And returns a status of the application to the OS. This status identifies some running information of the application. This information is related to the machine and operating system. Generally, 0 means a normal exit, and non-0 means an abnormal exit.
5. The effect of calling return and exit in non-main function is very obvious, but the phenomenon of calling return and exit in main function is very vague. In most cases, the phenomenon is the same
The above is the detailed content of What is the difference between PHP return and exit?. For more information, please follow other related articles on the PHP Chinese website!