The difference between die (), exit (), and return in PHP

Source: Internet
Author: User

Die () Stop program run, output content
Exit is to stop the program from running, not output content
Return is the returned value
Die is not stopped until it encounters an error
Exit is stopped directly and no subsequent code is run, and exit () can display the content.
Return is a purely returned value, but no subsequent code will be run
Exit (0): Run the program normally and exit the program;
Exit (1): Abnormal operation results in exiting the program;
Return (): Returns a function that, if in the main function, exits the function and returns a value.
Detailed said:
1. Return returns the function value, which is the keyword; exit is a function.
2. Return is a language level that represents the return of the call stack, and exit is the system call level, which represents the end of a process.
3. Return is the exit of the function (return); Exit is the exit of the process.
4. Return is provided by the C language, and exit is provided by the operating system (or given in the function library).
5. Return is used to end the execution of a function, using the execution information of the function out of other calling functions; the exit function exits the application, deletes the memory space used by the process, and returns a state of the application to the OS, which identifies some of the application's operational information. This information is related to the machine and the operating system, usually 0 for normal exit, not 0 for abnormal exit.

The difference between die (), exit (), and return in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.