|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-05-27 14:15 UTC] ml at vulnscan dot org
Description:
------------
die() returns exit status 0 (success), which is IMHO illogical.
This mostly matters when using PHP-CLI, for example where you have the usual:
@mysql_connect(..) or die('sql blahblah');
...in that case a success error code is returned.
I had this in an authentication callback script which returns 0 on user success and any other value on user failure.
In this case it returned 'success' in case of a SQL server error.
The only workaround I can see is first printing the error message, and then doing an explicit die/exit with a numerical value. This does not exactly improve code readability/niceness. And, like I said, I simply didn't expect die() to return a success exit code.
Test script:
---------------
<? die('abc'); ?>
Expected result:
----------------
I expect a non-zero exit code, instead of 0 (success).
Actual result:
--------------
Exit status of 0 (success)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 00:00:01 2025 UTC |
You can easily do this in your own code with a simple wrapper: ml_die($message,$code) { echo $message; die($code); }