Just like what is the difference between the following code {code...} and {code? Humbly ask the experts for advice, just like
The following code
Echo 'configuration error'; exit (3); // Status 3 indicates exit due to configuration error
And
// Exit directly ('configuration error ');
What is the difference?
I would like to ask you a question or two.
Reply content:
Just like
The following code
Echo 'configuration error'; exit (3); // Status 3 indicates exit due to configuration error
And
// Exit directly ('configuration error ');
What is the difference?
I would like to ask you a question or two.
First, let's draw a conclusion: there are slight differences.
Let's talk about the truth in the document:
If status is a string, this function prints the status just before exiting.
If status is an integer, that value will be used as the exit status and not printed. exit statuses shoshould be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. the status 0 is used to terminate the program successfully.
Note: PHP> = 4.2.0 does NOT print the status if it is an integer.
Simply put, if it is a string, it will be printed. if it is a number, it will be usedExit status code, Will not be printed.
Execute the above two lines of code separately. Obviously, the results are the same.
The difference is:
Comment out the second line and execute the following command on the terminal:
Php test. php // Print "error"
Echo $? //Print 3
Comment out the first line. run the following command on the terminal:
Php test. php // Print "error"
Echo $? //Print 0
That is to say, when the value of eixt () is int type, it is used as the exit status code.
$? Explanation: Stores the exit value of the last command that was executed (exit status of the last command, 0 indicates no error ).