The difference between Die,die (), Exit,exit (), Return,return () in PHP

Source: Internet
Author: User
Tags exit in

Die: Stop when you encounter an error
Die (): Stop program run, output content

Exit: Is the stop program running, is directly stopped, and does not run subsequent code, does not output content
Exit (): content can be displayed.
Exit (0): Run the program normally and exit the program;
Exit (1): Abnormal operation results in exiting the program;

Return: Is purely a return value, but will not run subsequent code
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.
6. Calling return and exit in a non-main function is obvious, but the phenomenon of calling return and exit in the main function is blurred, and in most cases the phenomenon is consistent

The difference between Die,die (), Exit,exit (), Return,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.