note 126902 added to function.die

From: Date: Mon, 07 Mar 2022 05:52:27 +0000
Subject: note 126902 added to function.die
Groups: php.notes 
Request: Send a blank email to php-notes+get-217687@lists.php.net to get a copy of this message
"... OR DIE..." <?php do_something($with_this) or die ('oops!'); ?> (in php, "die" is actually an alias of "exit") beware until this is often used as an error handling statement actually isn't... is just the "or" boolean operator overloaded (short circuited) it won't supress any error message, won't prevent you for fatal errors or crashes, is not an alias for "try/catch", and could has unpredictable results... it just means something like this: - execute the first statement ""do_something($with_this)"" normally -- if the statement results TRUE: no need to execute the second statement so skip it -- else if returns FALSE... well i am not sure about the result of the whole expression, so continue with second statement ""die('cuack!)"" so you can't rely on all statements will suppress error messages or crashes, or will always return "false" on error or undesirable behavior... for this better use the error skipping operator "@" "if" and "exit" commands, or use "try/catch" blocks ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 186.11.118.10) ---- Manual Page -- https://php.net/manual/en/function.die.php Edit -- https://main.php.net/note/edit/126902 Del: integrated -- https://main.php.net/note/delete/126902/integrated Del: useless -- https://main.php.net/note/delete/126902/useless Del: bad code -- https://main.php.net/note/delete/126902/bad+code Del: spam -- https://main.php.net/note/delete/126902/spam Del: non-english -- https://main.php.net/note/delete/126902/non-english Del: in docs -- https://main.php.net/note/delete/126902/in+docs Del: other reasons-- https://main.php.net/note/delete/126902 Reject -- https://main.php.net/note/reject/126902 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217687) next »