Just like
The following code
echo '配置错误';exit(3); //状态3表示由于配置错误而退出
And
// 直接退出exit('配置错误');
What's the difference?
Humbly ask the great God one or two
Reply content:
Just like
The following code
echo '配置错误';exit(3); //状态3表示由于配置错误而退出
And
// 直接退出exit('配置错误');
What's the difference?
Humbly ask the great God one or two
Give the conclusion first: there are subtle differences.
To speak the truth or to take a document:
If status is a string, this function prints the status just before exiting.
If status is a integer, that value would be used as the exit status and not printed. Exit statuses should be in the range 0 to 254, the exit status 255 are reserved by PHP and shall not being used. The status 0 is used to terminate the program successfully.
note:php >= 4.2.0 does not print the status if it's an integer.
Simply put: If it is a string, it will print out, if it is a number, it will be the exit status code , will not be printed.
Executing the two lines of code separately, it is clear that the result is the same.
The difference is:
Comment on the second line, execute the following command at the terminal:
PHP test.php//print "error"
echo $? Printing 3
Comment on the first line, execute the following command at the terminal:
PHP test.php//print "error"
echo $? Printing 0
That is, Eixt () is used as an exit status code when the argument is of type int.
$? Explanation: Stores The exit value of the last command is executed (the exit state of the final one, 0 means no error).