Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>
What is the difference between die()
and exit()
functions in PHP
I think the two have the same function, but I wonder if there are some differences between the two… What is this
#1st floor
As mentioned earlier, the two commands produce the same parser token
But
One small difference is how long it takes for the parser to return the token
I haven’t studied the PHP parser yet, but if it’s a long string of functions that start with “d” and a short string of functions that start with “e”, it’s going to take some time to find the function name of the function that starts with “.” e “. There may be other differences due to the way the entire function name is checked
I doubt it will be measurable unless you have a “perfect” environment dedicated to parsing PHP and many requests with different parameters. But there must be a difference. After all, PHP is an interpretive language
#2nd floor
There’s no difference – they’re the same
PHP Exit
Manual:
Note: this language construction is equivalent to
die()
PHP die
Manual:
This language construction is equivalent to
exit()
#3rd floor
They are essentially the same, although there are other suggestions in this paper
#4th floor
They sound similar, but exit () also allows you to set the exit code for the PHP script
Usually, you don’t actually need this script, but when writing a console PHP script, you may need to check with bash that the script does everything in the right way
You can then use exit () and capture later. Die() is not supported
Die() always exists as code 0. So essentially, the die() command does the following:
<?php
echo "I am going to die";
exit(0);
?>
Same as the following:
<?php
die("I am going to die");
?>
#5th floor
Mold in PHP manual:
Die – equivalent to exit
You can even die
and exit
same - with or without brackets
The only advantage of choosing die()
instead of exit()
may be that it saves time typing extra letters; -)
Similar Posts:
- Java system. Currenttimemillis() and system. Nanotime
- Error in compiling APR util for Linux
- OS X: equivalent to WGet of Linux
- [unity] to solve the problem of error reporting in the custom rule tile menu script of 2D extras
- How to Solve PHP Error: Function name must be a string
- [Solved] JSCH cannot run JAVA bash:java:Command not found.
- [Solved] Clang: error: linker command failed with exit code 1
- [How to Solve] expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__
- ”Cannot read property ‘addEventListener’ of null“
- [Solved] Node Error: DeprecationWarning: current URL string parser is deprecated and Port 3000 is already in use