Re: Question: Should exit() print out the integer exit-status?
| From: | Vlad Krupin | Date: | Wed, 19 Dec 2001 01:15:31 +0000 |
| Subject: | Re: Question: Should exit() print out the integer exit-status? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-74326@lists.php.net to get a copy of this message | ||
Uh?
You probably do not want to see the returned code printed anyway (unless you are debugging and are lazy to get it in any other way). Chances are that the codes returned by exit() won't make much sense to anyone but the one who develops the code, and it's not too difficult to do:
echo 1;
exit(1);
There are ways to print out a message right before we exit. There aren't too many ways to return an error code. I can think of a very good reason why we might want the error code returned, but not prnted (in fact, a lot of reasons), and we don't have this functionality. Hence, at least if parameter to exit() is an int, we should just return the error code, *not* print it.
I know, nobody has called a vote, but I thought I'd express my opinion in the form of a vote anyway, since somebody asked:)
Vlad
Jani Taskinen wrote:
background information: http://bugs.php.net/bug.php?edit=1&id=11008 http://bugs.php.net/bug.php?edit=1&id=14574 exit() function is broken. Fixing the broken behaviour is the only real solution, IMO. One solution: - When passed argument is string: print out this string - When passed argument is integer: Don't print it, use it as exit-status This is what is the expected behaviour is and I really can't think of any good examples where this would fail. Nobody ever gave any. And to get the REAL users (not only Zeev's opinion) I'm sending this also to php-general.From manual:"The exit() function terminates execution of the script. It prints status just before exiting. If status is an integer, that value will be used as exit-status." This can be understood in many ways. If the status is integer, it is used as exit-status..but it's not clear that it's ALSO printed out which is simply buggy behaviour. Now, if general concencus amongs the users of PHP is that it should also print out the exit-status when it's an integer then 'shell_exit()' function should be added. --Jani